@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.
Files changed (563) hide show
  1. package/README.md +49 -2
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.js +5 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/auth/anthropic-device-flow.d.ts +53 -0
  6. package/dist/src/auth/anthropic-device-flow.js +208 -0
  7. package/dist/src/auth/anthropic-device-flow.js.map +1 -0
  8. package/dist/src/auth/precedence.d.ts +55 -0
  9. package/dist/src/auth/precedence.js +211 -0
  10. package/dist/src/auth/precedence.js.map +1 -0
  11. package/dist/src/auth/qwen-device-flow.d.ts +45 -0
  12. package/dist/src/auth/qwen-device-flow.js +179 -0
  13. package/dist/src/auth/qwen-device-flow.js.map +1 -0
  14. package/dist/src/auth/token-store.d.ts +66 -0
  15. package/dist/src/auth/token-store.js +151 -0
  16. package/dist/src/auth/token-store.js.map +1 -0
  17. package/dist/src/auth/types.d.ts +130 -0
  18. package/dist/src/auth/types.js +60 -0
  19. package/dist/src/auth/types.js.map +1 -0
  20. package/dist/src/code_assist/converter.d.ts +2 -1
  21. package/dist/src/code_assist/converter.js +1 -1
  22. package/dist/src/code_assist/converter.js.map +1 -1
  23. package/dist/src/code_assist/oauth2.js +2 -1
  24. package/dist/src/code_assist/oauth2.js.map +1 -1
  25. package/dist/src/config/config.d.ts +78 -3
  26. package/dist/src/config/config.js +159 -6
  27. package/dist/src/config/config.js.map +1 -1
  28. package/dist/src/config/endpoints.d.ts +60 -0
  29. package/dist/src/config/endpoints.js +126 -0
  30. package/dist/src/config/endpoints.js.map +1 -0
  31. package/dist/src/config/profileManager.d.ts +14 -4
  32. package/dist/src/config/profileManager.js +90 -11
  33. package/dist/src/config/profileManager.js.map +1 -1
  34. package/dist/src/core/client.js +16 -16
  35. package/dist/src/core/client.js.map +1 -1
  36. package/dist/src/core/contentGenerator.d.ts +4 -1
  37. package/dist/src/core/contentGenerator.js +3 -0
  38. package/dist/src/core/contentGenerator.js.map +1 -1
  39. package/dist/src/core/logger.d.ts +1 -0
  40. package/dist/src/core/logger.js +18 -0
  41. package/dist/src/core/logger.js.map +1 -1
  42. package/dist/src/core/loggingContentGenerator.d.ts +24 -0
  43. package/dist/src/core/loggingContentGenerator.js +89 -0
  44. package/dist/src/core/loggingContentGenerator.js.map +1 -0
  45. package/dist/src/core/nonInteractiveToolExecutor.js +17 -0
  46. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  47. package/dist/src/core/subagent.js +12 -10
  48. package/dist/src/core/subagent.js.map +1 -1
  49. package/dist/src/ide/ide-client.d.ts +2 -2
  50. package/dist/src/ide/ide-client.js +56 -18
  51. package/dist/src/ide/ide-client.js.map +1 -1
  52. package/dist/src/index.d.ts +11 -0
  53. package/dist/src/index.js +12 -0
  54. package/dist/src/index.js.map +1 -1
  55. package/dist/src/providers/BaseProvider.d.ts +149 -0
  56. package/dist/src/providers/BaseProvider.js +315 -0
  57. package/dist/src/providers/BaseProvider.js.map +1 -0
  58. package/dist/src/providers/IProvider.d.ts +1 -0
  59. package/dist/src/providers/IProviderManager.d.ts +5 -0
  60. package/dist/src/providers/LoggingProviderWrapper.d.ts +54 -0
  61. package/dist/src/providers/LoggingProviderWrapper.js +350 -0
  62. package/dist/src/providers/LoggingProviderWrapper.js.map +1 -0
  63. package/dist/src/providers/ProviderManager.d.ts +20 -1
  64. package/dist/src/providers/ProviderManager.js +236 -14
  65. package/dist/src/providers/ProviderManager.js.map +1 -1
  66. package/dist/src/providers/anthropic/AnthropicProvider.d.ts +20 -6
  67. package/dist/src/providers/anthropic/AnthropicProvider.js +172 -26
  68. package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
  69. package/dist/src/providers/gemini/GeminiProvider.d.ts +16 -7
  70. package/dist/src/providers/gemini/GeminiProvider.js +163 -148
  71. package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
  72. package/dist/src/providers/logging/ProviderContentExtractor.d.ts +27 -0
  73. package/dist/src/providers/logging/ProviderContentExtractor.js +198 -0
  74. package/dist/src/providers/logging/ProviderContentExtractor.js.map +1 -0
  75. package/dist/src/providers/logging/ProviderPerformanceTracker.d.ts +43 -0
  76. package/dist/src/providers/logging/ProviderPerformanceTracker.js +98 -0
  77. package/dist/src/providers/logging/ProviderPerformanceTracker.js.map +1 -0
  78. package/dist/src/providers/openai/OpenAIProvider.d.ts +53 -6
  79. package/dist/src/providers/openai/OpenAIProvider.js +373 -40
  80. package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
  81. package/dist/src/providers/openai/RESPONSES_API_MODELS.d.ts +1 -1
  82. package/dist/src/providers/openai/RESPONSES_API_MODELS.js +1 -0
  83. package/dist/src/providers/openai/RESPONSES_API_MODELS.js.map +1 -1
  84. package/dist/src/providers/openai/syntheticToolResponses.d.ts +52 -0
  85. package/dist/src/providers/openai/syntheticToolResponses.js +129 -0
  86. package/dist/src/providers/openai/syntheticToolResponses.js.map +1 -0
  87. package/dist/src/providers/types.d.ts +47 -0
  88. package/dist/src/services/git-stats-service.d.ts +32 -0
  89. package/dist/src/services/git-stats-service.js +22 -0
  90. package/dist/src/services/git-stats-service.js.map +1 -0
  91. package/dist/src/services/loopDetectionService.js +10 -6
  92. package/dist/src/services/loopDetectionService.js.map +1 -1
  93. package/dist/src/services/shellExecutionService.js +44 -8
  94. package/dist/src/services/shellExecutionService.js.map +1 -1
  95. package/dist/src/settings/SettingsService.d.ts +32 -0
  96. package/dist/src/settings/SettingsService.js +204 -0
  97. package/dist/src/settings/SettingsService.js.map +1 -0
  98. package/dist/src/settings/settingsServiceInstance.d.ts +12 -0
  99. package/dist/src/settings/settingsServiceInstance.js +24 -0
  100. package/dist/src/settings/settingsServiceInstance.js.map +1 -0
  101. package/dist/src/settings/types.d.ts +141 -0
  102. package/dist/src/settings/types.js +5 -0
  103. package/dist/src/settings/types.js.map +1 -0
  104. package/dist/src/storage/ConversationFileWriter.d.ts +16 -0
  105. package/dist/src/storage/ConversationFileWriter.js +69 -0
  106. package/dist/src/storage/ConversationFileWriter.js.map +1 -0
  107. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +8 -0
  108. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +56 -3
  109. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  110. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +5 -1
  111. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +11 -0
  112. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  113. package/dist/src/telemetry/constants.d.ts +5 -0
  114. package/dist/src/telemetry/constants.js +5 -0
  115. package/dist/src/telemetry/constants.js.map +1 -1
  116. package/dist/src/telemetry/loggers.d.ts +5 -1
  117. package/dist/src/telemetry/loggers.js +87 -1
  118. package/dist/src/telemetry/loggers.js.map +1 -1
  119. package/dist/src/telemetry/metrics.d.ts +2 -1
  120. package/dist/src/telemetry/metrics.js +7 -1
  121. package/dist/src/telemetry/metrics.js.map +1 -1
  122. package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
  123. package/dist/src/telemetry/tool-call-decision.js +29 -0
  124. package/dist/src/telemetry/tool-call-decision.js.map +1 -0
  125. package/dist/src/telemetry/types.d.ts +56 -1
  126. package/dist/src/telemetry/types.js +123 -0
  127. package/dist/src/telemetry/types.js.map +1 -1
  128. package/dist/src/telemetry/uiTelemetry.d.ts +2 -1
  129. package/dist/src/telemetry/uiTelemetry.js +1 -1
  130. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  131. package/dist/src/tools/diffOptions.d.ts +2 -0
  132. package/dist/src/tools/diffOptions.js +28 -0
  133. package/dist/src/tools/diffOptions.js.map +1 -1
  134. package/dist/src/tools/edit.d.ts +8 -32
  135. package/dist/src/tools/edit.js +153 -136
  136. package/dist/src/tools/edit.js.map +1 -1
  137. package/dist/src/tools/glob.d.ts +3 -10
  138. package/dist/src/tools/glob.js +97 -99
  139. package/dist/src/tools/glob.js.map +1 -1
  140. package/dist/src/tools/grep.d.ts +3 -35
  141. package/dist/src/tools/grep.js +117 -88
  142. package/dist/src/tools/grep.js.map +1 -1
  143. package/dist/src/tools/mcp-client.d.ts +4 -3
  144. package/dist/src/tools/mcp-client.js +23 -6
  145. package/dist/src/tools/mcp-client.js.map +1 -1
  146. package/dist/src/tools/read-file.js +37 -9
  147. package/dist/src/tools/read-file.js.map +1 -1
  148. package/dist/src/tools/todo-pause.d.ts +22 -0
  149. package/dist/src/tools/todo-pause.js +93 -0
  150. package/dist/src/tools/todo-pause.js.map +1 -0
  151. package/dist/src/tools/tool-error.d.ts +4 -0
  152. package/dist/src/tools/tool-error.js +4 -0
  153. package/dist/src/tools/tool-error.js.map +1 -1
  154. package/dist/src/tools/tool-registry.js +3 -3
  155. package/dist/src/tools/tool-registry.js.map +1 -1
  156. package/dist/src/tools/tools.d.ts +18 -0
  157. package/dist/src/tools/tools.js +15 -0
  158. package/dist/src/tools/tools.js.map +1 -1
  159. package/dist/src/tools/write-file.d.ts +4 -0
  160. package/dist/src/tools/write-file.js +90 -16
  161. package/dist/src/tools/write-file.js.map +1 -1
  162. package/dist/src/types/modelParams.d.ts +2 -0
  163. package/dist/src/utils/environmentContext.js +1 -1
  164. package/dist/src/utils/errors.d.ts +3 -0
  165. package/dist/src/utils/errors.js +6 -0
  166. package/dist/src/utils/errors.js.map +1 -1
  167. package/dist/src/utils/fileUtils.d.ts +7 -0
  168. package/dist/src/utils/fileUtils.js +9 -0
  169. package/dist/src/utils/fileUtils.js.map +1 -1
  170. package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
  171. package/dist/src/utils/filesearch/fileSearch.js +27 -19
  172. package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
  173. package/package.json +4 -2
  174. package/dist/src/code_assist/converter.test.d.ts +0 -6
  175. package/dist/src/code_assist/converter.test.js +0 -232
  176. package/dist/src/code_assist/converter.test.js.map +0 -1
  177. package/dist/src/code_assist/oauth2.test.d.ts +0 -6
  178. package/dist/src/code_assist/oauth2.test.js +0 -370
  179. package/dist/src/code_assist/oauth2.test.js.map +0 -1
  180. package/dist/src/code_assist/server.test.d.ts +0 -6
  181. package/dist/src/code_assist/server.test.js +0 -131
  182. package/dist/src/code_assist/server.test.js.map +0 -1
  183. package/dist/src/code_assist/setup.test.d.ts +0 -6
  184. package/dist/src/code_assist/setup.test.js +0 -65
  185. package/dist/src/code_assist/setup.test.js.map +0 -1
  186. package/dist/src/config/config.alwaysAllow.test.d.ts +0 -6
  187. package/dist/src/config/config.alwaysAllow.test.js +0 -84
  188. package/dist/src/config/config.alwaysAllow.test.js.map +0 -1
  189. package/dist/src/config/config.test.d.ts +0 -6
  190. package/dist/src/config/config.test.js +0 -361
  191. package/dist/src/config/config.test.js.map +0 -1
  192. package/dist/src/config/flashFallback.test.d.ts +0 -6
  193. package/dist/src/config/flashFallback.test.js +0 -91
  194. package/dist/src/config/flashFallback.test.js.map +0 -1
  195. package/dist/src/core/client.test.d.ts +0 -6
  196. package/dist/src/core/client.test.js +0 -1317
  197. package/dist/src/core/client.test.js.map +0 -1
  198. package/dist/src/core/contentGenerator.test.d.ts +0 -6
  199. package/dist/src/core/contentGenerator.test.js +0 -103
  200. package/dist/src/core/contentGenerator.test.js.map +0 -1
  201. package/dist/src/core/coreToolScheduler.test.d.ts +0 -6
  202. package/dist/src/core/coreToolScheduler.test.js +0 -637
  203. package/dist/src/core/coreToolScheduler.test.js.map +0 -1
  204. package/dist/src/core/geminiChat.test.d.ts +0 -6
  205. package/dist/src/core/geminiChat.test.js +0 -425
  206. package/dist/src/core/geminiChat.test.js.map +0 -1
  207. package/dist/src/core/googleGenAIWrapper.test.d.ts +0 -6
  208. package/dist/src/core/googleGenAIWrapper.test.js +0 -104
  209. package/dist/src/core/googleGenAIWrapper.test.js.map +0 -1
  210. package/dist/src/core/logger.test.d.ts +0 -6
  211. package/dist/src/core/logger.test.js +0 -438
  212. package/dist/src/core/logger.test.js.map +0 -1
  213. package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +0 -6
  214. package/dist/src/core/nonInteractiveToolExecutor.test.js +0 -165
  215. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +0 -1
  216. package/dist/src/core/prompts-async.test.d.ts +0 -6
  217. package/dist/src/core/prompts-async.test.js +0 -115
  218. package/dist/src/core/prompts-async.test.js.map +0 -1
  219. package/dist/src/core/prompts.test.d.ts +0 -6
  220. package/dist/src/core/prompts.test.js +0 -68
  221. package/dist/src/core/prompts.test.js.map +0 -1
  222. package/dist/src/core/subagent.test.d.ts +0 -6
  223. package/dist/src/core/subagent.test.js +0 -519
  224. package/dist/src/core/subagent.test.js.map +0 -1
  225. package/dist/src/core/tokenLimits.test.d.ts +0 -6
  226. package/dist/src/core/tokenLimits.test.js +0 -66
  227. package/dist/src/core/tokenLimits.test.js.map +0 -1
  228. package/dist/src/core/turn.test.d.ts +0 -6
  229. package/dist/src/core/turn.test.js +0 -366
  230. package/dist/src/core/turn.test.js.map +0 -1
  231. package/dist/src/hooks/tool-render-suppression-hook.test.d.ts +0 -6
  232. package/dist/src/hooks/tool-render-suppression-hook.test.js +0 -59
  233. package/dist/src/hooks/tool-render-suppression-hook.test.js.map +0 -1
  234. package/dist/src/ide/ide-installer.test.d.ts +0 -6
  235. package/dist/src/ide/ide-installer.test.js +0 -55
  236. package/dist/src/ide/ide-installer.test.js.map +0 -1
  237. package/dist/src/ide/ideContext.test.d.ts +0 -6
  238. package/dist/src/ide/ideContext.test.js +0 -265
  239. package/dist/src/ide/ideContext.test.js.map +0 -1
  240. package/dist/src/index.test.d.ts +0 -6
  241. package/dist/src/index.test.js +0 -12
  242. package/dist/src/index.test.js.map +0 -1
  243. package/dist/src/integration-tests/todo-system.test.d.ts +0 -6
  244. package/dist/src/integration-tests/todo-system.test.js +0 -46
  245. package/dist/src/integration-tests/todo-system.test.js.map +0 -1
  246. package/dist/src/mcp/google-auth-provider.test.d.ts +0 -6
  247. package/dist/src/mcp/google-auth-provider.test.js +0 -54
  248. package/dist/src/mcp/google-auth-provider.test.js.map +0 -1
  249. package/dist/src/mcp/oauth-provider.test.d.ts +0 -6
  250. package/dist/src/mcp/oauth-provider.test.js +0 -602
  251. package/dist/src/mcp/oauth-provider.test.js.map +0 -1
  252. package/dist/src/mcp/oauth-token-storage.test.d.ts +0 -6
  253. package/dist/src/mcp/oauth-token-storage.test.js +0 -205
  254. package/dist/src/mcp/oauth-token-storage.test.js.map +0 -1
  255. package/dist/src/mcp/oauth-utils.test.d.ts +0 -6
  256. package/dist/src/mcp/oauth-utils.test.js +0 -144
  257. package/dist/src/mcp/oauth-utils.test.js.map +0 -1
  258. package/dist/src/parsers/TextToolCallParser.multibyte.test.d.ts +0 -1
  259. package/dist/src/parsers/TextToolCallParser.multibyte.test.js +0 -42
  260. package/dist/src/parsers/TextToolCallParser.multibyte.test.js.map +0 -1
  261. package/dist/src/parsers/TextToolCallParser.test.d.ts +0 -1
  262. package/dist/src/parsers/TextToolCallParser.test.js +0 -225
  263. package/dist/src/parsers/TextToolCallParser.test.js.map +0 -1
  264. package/dist/src/prompt-config/TemplateEngine.test.d.ts +0 -1
  265. package/dist/src/prompt-config/TemplateEngine.test.js +0 -494
  266. package/dist/src/prompt-config/TemplateEngine.test.js.map +0 -1
  267. package/dist/src/prompt-config/prompt-cache.test.d.ts +0 -6
  268. package/dist/src/prompt-config/prompt-cache.test.js +0 -437
  269. package/dist/src/prompt-config/prompt-cache.test.js.map +0 -1
  270. package/dist/src/prompt-config/prompt-installer.test.d.ts +0 -7
  271. package/dist/src/prompt-config/prompt-installer.test.js +0 -503
  272. package/dist/src/prompt-config/prompt-installer.test.js.map +0 -1
  273. package/dist/src/prompt-config/prompt-loader.test.d.ts +0 -5
  274. package/dist/src/prompt-config/prompt-loader.test.js +0 -413
  275. package/dist/src/prompt-config/prompt-loader.test.js.map +0 -1
  276. package/dist/src/prompt-config/prompt-resolver.test.d.ts +0 -1
  277. package/dist/src/prompt-config/prompt-resolver.test.js +0 -529
  278. package/dist/src/prompt-config/prompt-resolver.test.js.map +0 -1
  279. package/dist/src/prompt-config/prompt-service.test.d.ts +0 -1
  280. package/dist/src/prompt-config/prompt-service.test.js +0 -811
  281. package/dist/src/prompt-config/prompt-service.test.js.map +0 -1
  282. package/dist/src/providers/ProviderManager.gemini-switch.test.d.ts +0 -6
  283. package/dist/src/providers/ProviderManager.gemini-switch.test.js +0 -57
  284. package/dist/src/providers/ProviderManager.gemini-switch.test.js.map +0 -1
  285. package/dist/src/providers/ProviderManager.test.d.ts +0 -6
  286. package/dist/src/providers/ProviderManager.test.js +0 -284
  287. package/dist/src/providers/ProviderManager.test.js.map +0 -1
  288. package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.d.ts +0 -6
  289. package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js +0 -273
  290. package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js.map +0 -1
  291. package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.d.ts +0 -1
  292. package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.js +0 -48
  293. package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.js.map +0 -1
  294. package/dist/src/providers/anthropic/AnthropicProvider.test.d.ts +0 -1
  295. package/dist/src/providers/anthropic/AnthropicProvider.test.js +0 -487
  296. package/dist/src/providers/anthropic/AnthropicProvider.test.js.map +0 -1
  297. package/dist/src/providers/gemini/GeminiProvider.integration.test.d.ts +0 -6
  298. package/dist/src/providers/gemini/GeminiProvider.integration.test.js +0 -126
  299. package/dist/src/providers/gemini/GeminiProvider.integration.test.js.map +0 -1
  300. package/dist/src/providers/gemini/GeminiProvider.test.d.ts +0 -6
  301. package/dist/src/providers/gemini/GeminiProvider.test.js +0 -136
  302. package/dist/src/providers/gemini/GeminiProvider.test.js.map +0 -1
  303. package/dist/src/providers/integration/multi-provider.integration.test.d.ts +0 -6
  304. package/dist/src/providers/integration/multi-provider.integration.test.js +0 -292
  305. package/dist/src/providers/integration/multi-provider.integration.test.js.map +0 -1
  306. package/dist/src/providers/openai/ConversationCache.accumTokens.test.d.ts +0 -1
  307. package/dist/src/providers/openai/ConversationCache.accumTokens.test.js +0 -97
  308. package/dist/src/providers/openai/ConversationCache.accumTokens.test.js.map +0 -1
  309. package/dist/src/providers/openai/ConversationCache.test.d.ts +0 -1
  310. package/dist/src/providers/openai/ConversationCache.test.js +0 -113
  311. package/dist/src/providers/openai/ConversationCache.test.js.map +0 -1
  312. package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.d.ts +0 -1
  313. package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.js +0 -189
  314. package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.js.map +0 -1
  315. package/dist/src/providers/openai/OpenAIProvider.integration.test.d.ts +0 -6
  316. package/dist/src/providers/openai/OpenAIProvider.integration.test.js +0 -125
  317. package/dist/src/providers/openai/OpenAIProvider.integration.test.js.map +0 -1
  318. package/dist/src/providers/openai/OpenAIProvider.responses.test.d.ts +0 -1
  319. package/dist/src/providers/openai/OpenAIProvider.responses.test.js +0 -350
  320. package/dist/src/providers/openai/OpenAIProvider.responses.test.js.map +0 -1
  321. package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.d.ts +0 -1
  322. package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.js +0 -213
  323. package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.js.map +0 -1
  324. package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.d.ts +0 -1
  325. package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.js +0 -59
  326. package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.js.map +0 -1
  327. package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.d.ts +0 -6
  328. package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.js +0 -105
  329. package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.js.map +0 -1
  330. package/dist/src/providers/openai/OpenAIProvider.switch.test.d.ts +0 -1
  331. package/dist/src/providers/openai/OpenAIProvider.switch.test.js +0 -256
  332. package/dist/src/providers/openai/OpenAIProvider.switch.test.js.map +0 -1
  333. package/dist/src/providers/openai/OpenAIProvider.test.d.ts +0 -16
  334. package/dist/src/providers/openai/OpenAIProvider.test.js +0 -620
  335. package/dist/src/providers/openai/OpenAIProvider.test.js.map +0 -1
  336. package/dist/src/providers/openai/ResponsesContextTrim.integration.test.d.ts +0 -1
  337. package/dist/src/providers/openai/ResponsesContextTrim.integration.test.js +0 -210
  338. package/dist/src/providers/openai/ResponsesContextTrim.integration.test.js.map +0 -1
  339. package/dist/src/providers/openai/__tests__/formatArrayResponse.test.d.ts +0 -1
  340. package/dist/src/providers/openai/__tests__/formatArrayResponse.test.js +0 -65
  341. package/dist/src/providers/openai/__tests__/formatArrayResponse.test.js.map +0 -1
  342. package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.d.ts +0 -1
  343. package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.js +0 -129
  344. package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.js.map +0 -1
  345. package/dist/src/providers/openai/buildResponsesRequest.test.d.ts +0 -1
  346. package/dist/src/providers/openai/buildResponsesRequest.test.js +0 -406
  347. package/dist/src/providers/openai/buildResponsesRequest.test.js.map +0 -1
  348. package/dist/src/providers/openai/buildResponsesRequest.undefined.test.d.ts +0 -1
  349. package/dist/src/providers/openai/buildResponsesRequest.undefined.test.js +0 -50
  350. package/dist/src/providers/openai/buildResponsesRequest.undefined.test.js.map +0 -1
  351. package/dist/src/providers/openai/estimateRemoteTokens.test.d.ts +0 -1
  352. package/dist/src/providers/openai/estimateRemoteTokens.test.js +0 -125
  353. package/dist/src/providers/openai/estimateRemoteTokens.test.js.map +0 -1
  354. package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.d.ts +0 -1
  355. package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.js +0 -192
  356. package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.js.map +0 -1
  357. package/dist/src/providers/openai/parseResponsesStream.test.d.ts +0 -1
  358. package/dist/src/providers/openai/parseResponsesStream.test.js +0 -151
  359. package/dist/src/providers/openai/parseResponsesStream.test.js.map +0 -1
  360. package/dist/src/services/fileDiscoveryService.test.d.ts +0 -6
  361. package/dist/src/services/fileDiscoveryService.test.js +0 -143
  362. package/dist/src/services/fileDiscoveryService.test.js.map +0 -1
  363. package/dist/src/services/gitService.test.d.ts +0 -6
  364. package/dist/src/services/gitService.test.js +0 -209
  365. package/dist/src/services/gitService.test.js.map +0 -1
  366. package/dist/src/services/loopDetectionService.test.d.ts +0 -6
  367. package/dist/src/services/loopDetectionService.test.js +0 -345
  368. package/dist/src/services/loopDetectionService.test.js.map +0 -1
  369. package/dist/src/services/shellExecutionService.multibyte.test.d.ts +0 -6
  370. package/dist/src/services/shellExecutionService.multibyte.test.js +0 -72
  371. package/dist/src/services/shellExecutionService.multibyte.test.js.map +0 -1
  372. package/dist/src/services/shellExecutionService.test.d.ts +0 -6
  373. package/dist/src/services/shellExecutionService.test.js +0 -272
  374. package/dist/src/services/shellExecutionService.test.js.map +0 -1
  375. package/dist/src/services/shellExecutionService.windows.multibyte.test.d.ts +0 -6
  376. package/dist/src/services/shellExecutionService.windows.multibyte.test.js +0 -98
  377. package/dist/src/services/shellExecutionService.windows.multibyte.test.js.map +0 -1
  378. package/dist/src/services/shellExecutionService.windows.test.d.ts +0 -6
  379. package/dist/src/services/shellExecutionService.windows.test.js +0 -79
  380. package/dist/src/services/shellExecutionService.windows.test.js.map +0 -1
  381. package/dist/src/services/tool-call-tracker-service.test.d.ts +0 -6
  382. package/dist/src/services/tool-call-tracker-service.test.js +0 -99
  383. package/dist/src/services/tool-call-tracker-service.test.js.map +0 -1
  384. package/dist/src/telemetry/loggers.test.d.ts +0 -6
  385. package/dist/src/telemetry/loggers.test.js +0 -572
  386. package/dist/src/telemetry/loggers.test.js.map +0 -1
  387. package/dist/src/telemetry/metrics.test.d.ts +0 -6
  388. package/dist/src/telemetry/metrics.test.js +0 -162
  389. package/dist/src/telemetry/metrics.test.js.map +0 -1
  390. package/dist/src/telemetry/telemetry.test.d.ts +0 -6
  391. package/dist/src/telemetry/telemetry.test.js +0 -54
  392. package/dist/src/telemetry/telemetry.test.js.map +0 -1
  393. package/dist/src/telemetry/uiTelemetry.test.d.ts +0 -6
  394. package/dist/src/telemetry/uiTelemetry.test.js +0 -517
  395. package/dist/src/telemetry/uiTelemetry.test.js.map +0 -1
  396. package/dist/src/tools/ToolFormatter.test.d.ts +0 -16
  397. package/dist/src/tools/ToolFormatter.test.js +0 -349
  398. package/dist/src/tools/ToolFormatter.test.js.map +0 -1
  399. package/dist/src/tools/ToolFormatter.toResponsesTool.test.d.ts +0 -1
  400. package/dist/src/tools/ToolFormatter.toResponsesTool.test.js +0 -241
  401. package/dist/src/tools/ToolFormatter.toResponsesTool.test.js.map +0 -1
  402. package/dist/src/tools/edit.test.d.ts +0 -6
  403. package/dist/src/tools/edit.test.js +0 -663
  404. package/dist/src/tools/edit.test.js.map +0 -1
  405. package/dist/src/tools/glob.test.d.ts +0 -6
  406. package/dist/src/tools/glob.test.js +0 -321
  407. package/dist/src/tools/glob.test.js.map +0 -1
  408. package/dist/src/tools/grep.test.d.ts +0 -6
  409. package/dist/src/tools/grep.test.js +0 -258
  410. package/dist/src/tools/grep.test.js.map +0 -1
  411. package/dist/src/tools/ls.test.d.ts +0 -6
  412. package/dist/src/tools/ls.test.js +0 -357
  413. package/dist/src/tools/ls.test.js.map +0 -1
  414. package/dist/src/tools/mcp-client.test.d.ts +0 -6
  415. package/dist/src/tools/mcp-client.test.js +0 -575
  416. package/dist/src/tools/mcp-client.test.js.map +0 -1
  417. package/dist/src/tools/mcp-tool.test.d.ts +0 -6
  418. package/dist/src/tools/mcp-tool.test.js +0 -501
  419. package/dist/src/tools/mcp-tool.test.js.map +0 -1
  420. package/dist/src/tools/memoryTool.test.d.ts +0 -6
  421. package/dist/src/tools/memoryTool.test.js +0 -266
  422. package/dist/src/tools/memoryTool.test.js.map +0 -1
  423. package/dist/src/tools/modifiable-tool.test.d.ts +0 -6
  424. package/dist/src/tools/modifiable-tool.test.js +0 -193
  425. package/dist/src/tools/modifiable-tool.test.js.map +0 -1
  426. package/dist/src/tools/read-file.test.d.ts +0 -6
  427. package/dist/src/tools/read-file.test.js +0 -313
  428. package/dist/src/tools/read-file.test.js.map +0 -1
  429. package/dist/src/tools/read-many-files.test.d.ts +0 -6
  430. package/dist/src/tools/read-many-files.test.js +0 -644
  431. package/dist/src/tools/read-many-files.test.js.map +0 -1
  432. package/dist/src/tools/shell.multibyte.test.d.ts +0 -6
  433. package/dist/src/tools/shell.multibyte.test.js +0 -75
  434. package/dist/src/tools/shell.multibyte.test.js.map +0 -1
  435. package/dist/src/tools/shell.test.d.ts +0 -6
  436. package/dist/src/tools/shell.test.js +0 -350
  437. package/dist/src/tools/shell.test.js.map +0 -1
  438. package/dist/src/tools/todo-read.test.d.ts +0 -6
  439. package/dist/src/tools/todo-read.test.js +0 -162
  440. package/dist/src/tools/todo-read.test.js.map +0 -1
  441. package/dist/src/tools/todo-schemas.test.d.ts +0 -6
  442. package/dist/src/tools/todo-schemas.test.js +0 -341
  443. package/dist/src/tools/todo-schemas.test.js.map +0 -1
  444. package/dist/src/tools/todo-store.test.d.ts +0 -6
  445. package/dist/src/tools/todo-store.test.js +0 -169
  446. package/dist/src/tools/todo-store.test.js.map +0 -1
  447. package/dist/src/tools/todo-write.test.d.ts +0 -6
  448. package/dist/src/tools/todo-write.test.js +0 -226
  449. package/dist/src/tools/todo-write.test.js.map +0 -1
  450. package/dist/src/tools/tool-registry.test.d.ts +0 -6
  451. package/dist/src/tools/tool-registry.test.js +0 -468
  452. package/dist/src/tools/tool-registry.test.js.map +0 -1
  453. package/dist/src/tools/tools.test.d.ts +0 -6
  454. package/dist/src/tools/tools.test.js +0 -117
  455. package/dist/src/tools/tools.test.js.map +0 -1
  456. package/dist/src/tools/web-fetch.integration.test.d.ts +0 -6
  457. package/dist/src/tools/web-fetch.integration.test.js +0 -532
  458. package/dist/src/tools/web-fetch.integration.test.js.map +0 -1
  459. package/dist/src/tools/web-search.test.d.ts +0 -6
  460. package/dist/src/tools/web-search.test.js +0 -229
  461. package/dist/src/tools/web-search.test.js.map +0 -1
  462. package/dist/src/tools/write-file.test.d.ts +0 -6
  463. package/dist/src/tools/write-file.test.js +0 -464
  464. package/dist/src/tools/write-file.test.js.map +0 -1
  465. package/dist/src/utils/bfsFileSearch.test.d.ts +0 -6
  466. package/dist/src/utils/bfsFileSearch.test.js +0 -191
  467. package/dist/src/utils/bfsFileSearch.test.js.map +0 -1
  468. package/dist/src/utils/editCorrector.test.d.ts +0 -6
  469. package/dist/src/utils/editCorrector.test.js +0 -564
  470. package/dist/src/utils/editCorrector.test.js.map +0 -1
  471. package/dist/src/utils/editor.test.d.ts +0 -6
  472. package/dist/src/utils/editor.test.js +0 -445
  473. package/dist/src/utils/editor.test.js.map +0 -1
  474. package/dist/src/utils/environmentContext.test.d.ts +0 -6
  475. package/dist/src/utils/environmentContext.test.js +0 -139
  476. package/dist/src/utils/environmentContext.test.js.map +0 -1
  477. package/dist/src/utils/errorReporting.test.d.ts +0 -6
  478. package/dist/src/utils/errorReporting.test.js +0 -130
  479. package/dist/src/utils/errorReporting.test.js.map +0 -1
  480. package/dist/src/utils/fileUtils.test.d.ts +0 -6
  481. package/dist/src/utils/fileUtils.test.js +0 -363
  482. package/dist/src/utils/fileUtils.test.js.map +0 -1
  483. package/dist/src/utils/filesearch/crawlCache.test.d.ts +0 -6
  484. package/dist/src/utils/filesearch/crawlCache.test.js +0 -103
  485. package/dist/src/utils/filesearch/crawlCache.test.js.map +0 -1
  486. package/dist/src/utils/filesearch/fileSearch.test.d.ts +0 -6
  487. package/dist/src/utils/filesearch/fileSearch.test.js +0 -654
  488. package/dist/src/utils/filesearch/fileSearch.test.js.map +0 -1
  489. package/dist/src/utils/filesearch/ignore.test.d.ts +0 -6
  490. package/dist/src/utils/filesearch/ignore.test.js +0 -57
  491. package/dist/src/utils/filesearch/ignore.test.js.map +0 -1
  492. package/dist/src/utils/filesearch/result-cache.test.d.ts +0 -6
  493. package/dist/src/utils/filesearch/result-cache.test.js +0 -47
  494. package/dist/src/utils/filesearch/result-cache.test.js.map +0 -1
  495. package/dist/src/utils/flashFallback.integration.test.d.ts +0 -6
  496. package/dist/src/utils/flashFallback.integration.test.js +0 -120
  497. package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
  498. package/dist/src/utils/generateContentResponseUtilities.test.d.ts +0 -6
  499. package/dist/src/utils/generateContentResponseUtilities.test.js +0 -273
  500. package/dist/src/utils/generateContentResponseUtilities.test.js.map +0 -1
  501. package/dist/src/utils/getFolderStructure.test.d.ts +0 -6
  502. package/dist/src/utils/getFolderStructure.test.js +0 -282
  503. package/dist/src/utils/getFolderStructure.test.js.map +0 -1
  504. package/dist/src/utils/gitIgnoreParser.test.d.ts +0 -6
  505. package/dist/src/utils/gitIgnoreParser.test.js +0 -154
  506. package/dist/src/utils/gitIgnoreParser.test.js.map +0 -1
  507. package/dist/src/utils/memoryDiscovery.test.d.ts +0 -6
  508. package/dist/src/utils/memoryDiscovery.test.js +0 -181
  509. package/dist/src/utils/memoryDiscovery.test.js.map +0 -1
  510. package/dist/src/utils/memoryImportProcessor.test.d.ts +0 -6
  511. package/dist/src/utils/memoryImportProcessor.test.js +0 -715
  512. package/dist/src/utils/memoryImportProcessor.test.js.map +0 -1
  513. package/dist/src/utils/nextSpeakerChecker.test.d.ts +0 -6
  514. package/dist/src/utils/nextSpeakerChecker.test.js +0 -172
  515. package/dist/src/utils/nextSpeakerChecker.test.js.map +0 -1
  516. package/dist/src/utils/partUtils.test.d.ts +0 -6
  517. package/dist/src/utils/partUtils.test.js +0 -130
  518. package/dist/src/utils/partUtils.test.js.map +0 -1
  519. package/dist/src/utils/paths.test.d.ts +0 -6
  520. package/dist/src/utils/paths.test.js +0 -153
  521. package/dist/src/utils/paths.test.js.map +0 -1
  522. package/dist/src/utils/retry.test.d.ts +0 -6
  523. package/dist/src/utils/retry.test.js +0 -322
  524. package/dist/src/utils/retry.test.js.map +0 -1
  525. package/dist/src/utils/safeJsonStringify.test.d.ts +0 -6
  526. package/dist/src/utils/safeJsonStringify.test.js +0 -61
  527. package/dist/src/utils/safeJsonStringify.test.js.map +0 -1
  528. package/dist/src/utils/sanitization.test.d.ts +0 -6
  529. package/dist/src/utils/sanitization.test.js +0 -81
  530. package/dist/src/utils/sanitization.test.js.map +0 -1
  531. package/dist/src/utils/schemaValidator.test.d.ts +0 -6
  532. package/dist/src/utils/schemaValidator.test.js +0 -146
  533. package/dist/src/utils/schemaValidator.test.js.map +0 -1
  534. package/dist/src/utils/secure-browser-launcher.test.d.ts +0 -6
  535. package/dist/src/utils/secure-browser-launcher.test.js +0 -149
  536. package/dist/src/utils/secure-browser-launcher.test.js.map +0 -1
  537. package/dist/src/utils/shell-utils.shellReplacement.test.d.ts +0 -6
  538. package/dist/src/utils/shell-utils.shellReplacement.test.js +0 -149
  539. package/dist/src/utils/shell-utils.shellReplacement.test.js.map +0 -1
  540. package/dist/src/utils/shell-utils.test.d.ts +0 -6
  541. package/dist/src/utils/shell-utils.test.js +0 -200
  542. package/dist/src/utils/shell-utils.test.js.map +0 -1
  543. package/dist/src/utils/summarizer.test.d.ts +0 -6
  544. package/dist/src/utils/summarizer.test.js +0 -131
  545. package/dist/src/utils/summarizer.test.js.map +0 -1
  546. package/dist/src/utils/systemEncoding.test.d.ts +0 -6
  547. package/dist/src/utils/systemEncoding.test.js +0 -368
  548. package/dist/src/utils/systemEncoding.test.js.map +0 -1
  549. package/dist/src/utils/toolOutputLimiter.test.d.ts +0 -6
  550. package/dist/src/utils/toolOutputLimiter.test.js +0 -164
  551. package/dist/src/utils/toolOutputLimiter.test.js.map +0 -1
  552. package/dist/src/utils/unicodeUtils.test.d.ts +0 -6
  553. package/dist/src/utils/unicodeUtils.test.js +0 -120
  554. package/dist/src/utils/unicodeUtils.test.js.map +0 -1
  555. package/dist/src/utils/user_account.test.d.ts +0 -6
  556. package/dist/src/utils/user_account.test.js +0 -153
  557. package/dist/src/utils/user_account.test.js.map +0 -1
  558. package/dist/src/utils/user_id.test.d.ts +0 -6
  559. package/dist/src/utils/user_id.test.js +0 -21
  560. package/dist/src/utils/user_id.test.js.map +0 -1
  561. package/dist/src/utils/workspaceContext.test.d.ts +0 -6
  562. package/dist/src/utils/workspaceContext.test.js +0 -209
  563. package/dist/src/utils/workspaceContext.test.js.map +0 -1
@@ -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 { BaseTool, Icon } from './tools.js';
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
- static Name = 'glob';
47
- constructor(config) {
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
- * Validates the parameters for the tool.
78
- */
79
- validateToolParams(params) {
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 && sortedEntries.length > params.max_files) {
209
- finalEntries = sortedEntries.slice(0, params.max_files);
210
- limitMessage = ` (showing first ${params.max_files} of ${sortedEntries.length} total matches)`;
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 (NOT item limiting - glob just lists paths)
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,EAAE,QAAQ,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,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AC;QAED,IACE,CAAC,MAAM,CAAC,OAAO;YACf,OAAO,MAAM,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"}
@@ -3,7 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { BaseTool, ToolResult } from './tools.js';
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 BaseTool<GrepToolParams, ToolResult> {
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
  }
@@ -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 { BaseTool, Icon } from './tools.js';
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
- // --- GrepLogic Class ---
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
- static Name = 'search_file_content'; // Keep static name
26
- constructor(config) {
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(params) {
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() || params.path === '.') {
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