@vybestack/llxprt-code-tools 0.10.0-nightly.260613.1adad3b34

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 (364) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +294 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +2 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.d.ts +29 -0
  8. package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.js +30 -0
  9. package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.js.map +1 -0
  10. package/dist/src/__tests__/fixtures/key-storage-fixtures.d.ts +39 -0
  11. package/dist/src/__tests__/fixtures/key-storage-fixtures.js +53 -0
  12. package/dist/src/__tests__/fixtures/key-storage-fixtures.js.map +1 -0
  13. package/dist/src/__tests__/fixtures/provider-formatting-fixtures.d.ts +140 -0
  14. package/dist/src/__tests__/fixtures/provider-formatting-fixtures.js +157 -0
  15. package/dist/src/__tests__/fixtures/provider-formatting-fixtures.js.map +1 -0
  16. package/dist/src/__tests__/red-test-helpers.d.ts +14 -0
  17. package/dist/src/__tests__/red-test-helpers.js +18 -0
  18. package/dist/src/__tests__/red-test-helpers.js.map +1 -0
  19. package/dist/src/formatters/IToolFormatter.d.ts +84 -0
  20. package/dist/src/formatters/IToolFormatter.js +6 -0
  21. package/dist/src/formatters/IToolFormatter.js.map +1 -0
  22. package/dist/src/formatters/ToolFormatter.d.ts +94 -0
  23. package/dist/src/formatters/ToolFormatter.js +379 -0
  24. package/dist/src/formatters/ToolFormatter.js.map +1 -0
  25. package/dist/src/formatters/ToolIdStrategy.d.ts +79 -0
  26. package/dist/src/formatters/ToolIdStrategy.js +173 -0
  27. package/dist/src/formatters/ToolIdStrategy.js.map +1 -0
  28. package/dist/src/formatters/doubleEscapeUtils.d.ts +46 -0
  29. package/dist/src/formatters/doubleEscapeUtils.js +223 -0
  30. package/dist/src/formatters/doubleEscapeUtils.js.map +1 -0
  31. package/dist/src/formatters/index.d.ts +21 -0
  32. package/dist/src/formatters/index.js +12 -0
  33. package/dist/src/formatters/index.js.map +1 -0
  34. package/dist/src/formatters/toolIdNormalization.d.ts +28 -0
  35. package/dist/src/formatters/toolIdNormalization.js +97 -0
  36. package/dist/src/formatters/toolIdNormalization.js.map +1 -0
  37. package/dist/src/formatters/toolNameUtils.d.ts +43 -0
  38. package/dist/src/formatters/toolNameUtils.js +143 -0
  39. package/dist/src/formatters/toolNameUtils.js.map +1 -0
  40. package/dist/src/index.d.ts +88 -0
  41. package/dist/src/index.js +68 -0
  42. package/dist/src/index.js.map +1 -0
  43. package/dist/src/interfaces/IAsyncTaskService.d.ts +57 -0
  44. package/dist/src/interfaces/IAsyncTaskService.js +6 -0
  45. package/dist/src/interfaces/IAsyncTaskService.js.map +1 -0
  46. package/dist/src/interfaces/IIdeService.d.ts +62 -0
  47. package/dist/src/interfaces/IIdeService.js +6 -0
  48. package/dist/src/interfaces/IIdeService.js.map +1 -0
  49. package/dist/src/interfaces/ILspService.d.ts +54 -0
  50. package/dist/src/interfaces/ILspService.js +6 -0
  51. package/dist/src/interfaces/ILspService.js.map +1 -0
  52. package/dist/src/interfaces/IMcpToolService.d.ts +47 -0
  53. package/dist/src/interfaces/IMcpToolService.js +6 -0
  54. package/dist/src/interfaces/IMcpToolService.js.map +1 -0
  55. package/dist/src/interfaces/IPromptRegistryService.d.ts +51 -0
  56. package/dist/src/interfaces/IPromptRegistryService.js +6 -0
  57. package/dist/src/interfaces/IPromptRegistryService.js.map +1 -0
  58. package/dist/src/interfaces/ISettingsService.d.ts +50 -0
  59. package/dist/src/interfaces/ISettingsService.js +6 -0
  60. package/dist/src/interfaces/ISettingsService.js.map +1 -0
  61. package/dist/src/interfaces/IShellExecutionService.d.ts +55 -0
  62. package/dist/src/interfaces/IShellExecutionService.js +6 -0
  63. package/dist/src/interfaces/IShellExecutionService.js.map +1 -0
  64. package/dist/src/interfaces/IShellToolHost.d.ts +176 -0
  65. package/dist/src/interfaces/IShellToolHost.js +6 -0
  66. package/dist/src/interfaces/IShellToolHost.js.map +1 -0
  67. package/dist/src/interfaces/ISkillService.d.ts +69 -0
  68. package/dist/src/interfaces/ISkillService.js +6 -0
  69. package/dist/src/interfaces/ISkillService.js.map +1 -0
  70. package/dist/src/interfaces/IStorageService.d.ts +42 -0
  71. package/dist/src/interfaces/IStorageService.js +6 -0
  72. package/dist/src/interfaces/IStorageService.js.map +1 -0
  73. package/dist/src/interfaces/ISubagentService.d.ts +112 -0
  74. package/dist/src/interfaces/ISubagentService.js +6 -0
  75. package/dist/src/interfaces/ISubagentService.js.map +1 -0
  76. package/dist/src/interfaces/ITaskToolHost.d.ts +185 -0
  77. package/dist/src/interfaces/ITaskToolHost.js +6 -0
  78. package/dist/src/interfaces/ITaskToolHost.js.map +1 -0
  79. package/dist/src/interfaces/ITodoService.d.ts +79 -0
  80. package/dist/src/interfaces/ITodoService.js +6 -0
  81. package/dist/src/interfaces/ITodoService.js.map +1 -0
  82. package/dist/src/interfaces/IToolHost.d.ts +91 -0
  83. package/dist/src/interfaces/IToolHost.js +6 -0
  84. package/dist/src/interfaces/IToolHost.js.map +1 -0
  85. package/dist/src/interfaces/IToolKeyStorage.d.ts +62 -0
  86. package/dist/src/interfaces/IToolKeyStorage.js +6 -0
  87. package/dist/src/interfaces/IToolKeyStorage.js.map +1 -0
  88. package/dist/src/interfaces/IToolMessageBus.d.ts +63 -0
  89. package/dist/src/interfaces/IToolMessageBus.js +6 -0
  90. package/dist/src/interfaces/IToolMessageBus.js.map +1 -0
  91. package/dist/src/interfaces/IToolRegistryHost.d.ts +43 -0
  92. package/dist/src/interfaces/IToolRegistryHost.js +6 -0
  93. package/dist/src/interfaces/IToolRegistryHost.js.map +1 -0
  94. package/dist/src/interfaces/IWebSearchService.d.ts +16 -0
  95. package/dist/src/interfaces/IWebSearchService.js +7 -0
  96. package/dist/src/interfaces/IWebSearchService.js.map +1 -0
  97. package/dist/src/interfaces/index.d.ts +33 -0
  98. package/dist/src/interfaces/index.js +6 -0
  99. package/dist/src/interfaces/index.js.map +1 -0
  100. package/dist/src/tools/activate-skill.d.ts +26 -0
  101. package/dist/src/tools/activate-skill.js +121 -0
  102. package/dist/src/tools/activate-skill.js.map +1 -0
  103. package/dist/src/tools/apply-patch.d.ts +65 -0
  104. package/dist/src/tools/apply-patch.js +528 -0
  105. package/dist/src/tools/apply-patch.js.map +1 -0
  106. package/dist/src/tools/ast-edit/ast-config.d.ts +67 -0
  107. package/dist/src/tools/ast-edit/ast-config.js +72 -0
  108. package/dist/src/tools/ast-edit/ast-config.js.map +1 -0
  109. package/dist/src/tools/ast-edit/ast-edit-invocation.d.ts +40 -0
  110. package/dist/src/tools/ast-edit/ast-edit-invocation.js +410 -0
  111. package/dist/src/tools/ast-edit/ast-edit-invocation.js.map +1 -0
  112. package/dist/src/tools/ast-edit/ast-query-extractor.d.ts +21 -0
  113. package/dist/src/tools/ast-edit/ast-query-extractor.js +178 -0
  114. package/dist/src/tools/ast-edit/ast-query-extractor.js.map +1 -0
  115. package/dist/src/tools/ast-edit/ast-read-file-invocation.d.ts +26 -0
  116. package/dist/src/tools/ast-edit/ast-read-file-invocation.js +149 -0
  117. package/dist/src/tools/ast-edit/ast-read-file-invocation.js.map +1 -0
  118. package/dist/src/tools/ast-edit/constants.d.ts +30 -0
  119. package/dist/src/tools/ast-edit/constants.js +36 -0
  120. package/dist/src/tools/ast-edit/constants.js.map +1 -0
  121. package/dist/src/tools/ast-edit/context-collector.d.ts +25 -0
  122. package/dist/src/tools/ast-edit/context-collector.js +115 -0
  123. package/dist/src/tools/ast-edit/context-collector.js.map +1 -0
  124. package/dist/src/tools/ast-edit/context-optimizer.d.ts +29 -0
  125. package/dist/src/tools/ast-edit/context-optimizer.js +86 -0
  126. package/dist/src/tools/ast-edit/context-optimizer.js.map +1 -0
  127. package/dist/src/tools/ast-edit/cross-file-analyzer.d.ts +41 -0
  128. package/dist/src/tools/ast-edit/cross-file-analyzer.js +294 -0
  129. package/dist/src/tools/ast-edit/cross-file-analyzer.js.map +1 -0
  130. package/dist/src/tools/ast-edit/edit-calculator.d.ts +71 -0
  131. package/dist/src/tools/ast-edit/edit-calculator.js +249 -0
  132. package/dist/src/tools/ast-edit/edit-calculator.js.map +1 -0
  133. package/dist/src/tools/ast-edit/edit-helpers.d.ts +22 -0
  134. package/dist/src/tools/ast-edit/edit-helpers.js +36 -0
  135. package/dist/src/tools/ast-edit/edit-helpers.js.map +1 -0
  136. package/dist/src/tools/ast-edit/language-analysis.d.ts +19 -0
  137. package/dist/src/tools/ast-edit/language-analysis.js +123 -0
  138. package/dist/src/tools/ast-edit/language-analysis.js.map +1 -0
  139. package/dist/src/tools/ast-edit/local-context-analyzer.d.ts +84 -0
  140. package/dist/src/tools/ast-edit/local-context-analyzer.js +267 -0
  141. package/dist/src/tools/ast-edit/local-context-analyzer.js.map +1 -0
  142. package/dist/src/tools/ast-edit/repository-context-provider.d.ts +22 -0
  143. package/dist/src/tools/ast-edit/repository-context-provider.js +139 -0
  144. package/dist/src/tools/ast-edit/repository-context-provider.js.map +1 -0
  145. package/dist/src/tools/ast-edit/types.d.ts +155 -0
  146. package/dist/src/tools/ast-edit/types.js +7 -0
  147. package/dist/src/tools/ast-edit/types.js.map +1 -0
  148. package/dist/src/tools/ast-edit/workspace-context-provider.d.ts +22 -0
  149. package/dist/src/tools/ast-edit/workspace-context-provider.js +39 -0
  150. package/dist/src/tools/ast-edit/workspace-context-provider.js.map +1 -0
  151. package/dist/src/tools/ast-edit.d.ts +43 -0
  152. package/dist/src/tools/ast-edit.js +183 -0
  153. package/dist/src/tools/ast-edit.js.map +1 -0
  154. package/dist/src/tools/ast-grep.d.ts +22 -0
  155. package/dist/src/tools/ast-grep.js +291 -0
  156. package/dist/src/tools/ast-grep.js.map +1 -0
  157. package/dist/src/tools/check-async-tasks.d.ts +46 -0
  158. package/dist/src/tools/check-async-tasks.js +241 -0
  159. package/dist/src/tools/check-async-tasks.js.map +1 -0
  160. package/dist/src/tools/codesearch.d.ts +25 -0
  161. package/dist/src/tools/codesearch.js +153 -0
  162. package/dist/src/tools/codesearch.js.map +1 -0
  163. package/dist/src/tools/delete_line_range.d.ts +41 -0
  164. package/dist/src/tools/delete_line_range.js +238 -0
  165. package/dist/src/tools/delete_line_range.js.map +1 -0
  166. package/dist/src/tools/direct-web-fetch.d.ts +22 -0
  167. package/dist/src/tools/direct-web-fetch.js +215 -0
  168. package/dist/src/tools/direct-web-fetch.js.map +1 -0
  169. package/dist/src/tools/edit-utils.d.ts +53 -0
  170. package/dist/src/tools/edit-utils.js +250 -0
  171. package/dist/src/tools/edit-utils.js.map +1 -0
  172. package/dist/src/tools/edit.d.ts +70 -0
  173. package/dist/src/tools/edit.js +816 -0
  174. package/dist/src/tools/edit.js.map +1 -0
  175. package/dist/src/tools/exa-web-search.d.ts +27 -0
  176. package/dist/src/tools/exa-web-search.js +153 -0
  177. package/dist/src/tools/exa-web-search.js.map +1 -0
  178. package/dist/src/tools/glob.d.ts +55 -0
  179. package/dist/src/tools/glob.js +284 -0
  180. package/dist/src/tools/glob.js.map +1 -0
  181. package/dist/src/tools/google-web-fetch.d.ts +34 -0
  182. package/dist/src/tools/google-web-fetch.js +417 -0
  183. package/dist/src/tools/google-web-fetch.js.map +1 -0
  184. package/dist/src/tools/google-web-search-invocation.d.ts +53 -0
  185. package/dist/src/tools/google-web-search-invocation.js +180 -0
  186. package/dist/src/tools/google-web-search-invocation.js.map +1 -0
  187. package/dist/src/tools/google-web-search.d.ts +16 -0
  188. package/dist/src/tools/google-web-search.js +34 -0
  189. package/dist/src/tools/google-web-search.js.map +1 -0
  190. package/dist/src/tools/grep.d.ts +56 -0
  191. package/dist/src/tools/grep.js +883 -0
  192. package/dist/src/tools/grep.js.map +1 -0
  193. package/dist/src/tools/insert_at_line.d.ts +41 -0
  194. package/dist/src/tools/insert_at_line.js +287 -0
  195. package/dist/src/tools/insert_at_line.js.map +1 -0
  196. package/dist/src/tools/list-subagents.d.ts +31 -0
  197. package/dist/src/tools/list-subagents.js +122 -0
  198. package/dist/src/tools/list-subagents.js.map +1 -0
  199. package/dist/src/tools/ls.d.ts +71 -0
  200. package/dist/src/tools/ls.js +238 -0
  201. package/dist/src/tools/ls.js.map +1 -0
  202. package/dist/src/tools/memoryTool.d.ts +66 -0
  203. package/dist/src/tools/memoryTool.js +435 -0
  204. package/dist/src/tools/memoryTool.js.map +1 -0
  205. package/dist/src/tools/modifiable-tool.d.ts +37 -0
  206. package/dist/src/tools/modifiable-tool.js +120 -0
  207. package/dist/src/tools/modifiable-tool.js.map +1 -0
  208. package/dist/src/tools/read-file.d.ts +49 -0
  209. package/dist/src/tools/read-file.js +279 -0
  210. package/dist/src/tools/read-file.js.map +1 -0
  211. package/dist/src/tools/read-many-files.d.ts +60 -0
  212. package/dist/src/tools/read-many-files.js +529 -0
  213. package/dist/src/tools/read-many-files.js.map +1 -0
  214. package/dist/src/tools/read_line_range.d.ts +47 -0
  215. package/dist/src/tools/read_line_range.js +248 -0
  216. package/dist/src/tools/read_line_range.js.map +1 -0
  217. package/dist/src/tools/ripGrep.d.ts +41 -0
  218. package/dist/src/tools/ripGrep.js +395 -0
  219. package/dist/src/tools/ripGrep.js.map +1 -0
  220. package/dist/src/tools/shell.d.ts +60 -0
  221. package/dist/src/tools/shell.js +735 -0
  222. package/dist/src/tools/shell.js.map +1 -0
  223. package/dist/src/tools/structural-analysis.d.ts +27 -0
  224. package/dist/src/tools/structural-analysis.js +1089 -0
  225. package/dist/src/tools/structural-analysis.js.map +1 -0
  226. package/dist/src/tools/stubs.d.ts +10 -0
  227. package/dist/src/tools/stubs.js +6 -0
  228. package/dist/src/tools/stubs.js.map +1 -0
  229. package/dist/src/tools/task.d.ts +41 -0
  230. package/dist/src/tools/task.js +195 -0
  231. package/dist/src/tools/task.js.map +1 -0
  232. package/dist/src/tools/todo-events.d.ts +22 -0
  233. package/dist/src/tools/todo-events.js +24 -0
  234. package/dist/src/tools/todo-events.js.map +1 -0
  235. package/dist/src/tools/todo-pause.d.ts +29 -0
  236. package/dist/src/tools/todo-pause.js +172 -0
  237. package/dist/src/tools/todo-pause.js.map +1 -0
  238. package/dist/src/tools/todo-read.d.ts +18 -0
  239. package/dist/src/tools/todo-read.js +98 -0
  240. package/dist/src/tools/todo-read.js.map +1 -0
  241. package/dist/src/tools/todo-store.d.ts +35 -0
  242. package/dist/src/tools/todo-store.js +124 -0
  243. package/dist/src/tools/todo-store.js.map +1 -0
  244. package/dist/src/tools/todo-write.d.ts +29 -0
  245. package/dist/src/tools/todo-write.js +366 -0
  246. package/dist/src/tools/todo-write.js.map +1 -0
  247. package/dist/src/tools/tool-registry.d.ts +156 -0
  248. package/dist/src/tools/tool-registry.js +623 -0
  249. package/dist/src/tools/tool-registry.js.map +1 -0
  250. package/dist/src/tools/tools.d.ts +403 -0
  251. package/dist/src/tools/tools.js +519 -0
  252. package/dist/src/tools/tools.js.map +1 -0
  253. package/dist/src/tools/write-file.d.ts +45 -0
  254. package/dist/src/tools/write-file.js +320 -0
  255. package/dist/src/tools/write-file.js.map +1 -0
  256. package/dist/src/types/index.d.ts +17 -0
  257. package/dist/src/types/index.js +9 -0
  258. package/dist/src/types/index.js.map +1 -0
  259. package/dist/src/types/provider-content-types.d.ts +56 -0
  260. package/dist/src/types/provider-content-types.js +6 -0
  261. package/dist/src/types/provider-content-types.js.map +1 -0
  262. package/dist/src/types/todo-schemas.d.ts +263 -0
  263. package/dist/src/types/todo-schemas.js +32 -0
  264. package/dist/src/types/todo-schemas.js.map +1 -0
  265. package/dist/src/types/tool-confirmation-types.d.ts +34 -0
  266. package/dist/src/types/tool-confirmation-types.js +29 -0
  267. package/dist/src/types/tool-confirmation-types.js.map +1 -0
  268. package/dist/src/types/tool-context.d.ts +31 -0
  269. package/dist/src/types/tool-context.js +6 -0
  270. package/dist/src/types/tool-context.js.map +1 -0
  271. package/dist/src/types/tool-error.d.ts +69 -0
  272. package/dist/src/types/tool-error.js +94 -0
  273. package/dist/src/types/tool-error.js.map +1 -0
  274. package/dist/src/types/tool-names.d.ts +57 -0
  275. package/dist/src/types/tool-names.js +64 -0
  276. package/dist/src/types/tool-names.js.map +1 -0
  277. package/dist/src/utils/EmojiFilter.d.ts +134 -0
  278. package/dist/src/utils/EmojiFilter.js +370 -0
  279. package/dist/src/utils/EmojiFilter.js.map +1 -0
  280. package/dist/src/utils/ast-grep-utils.d.ts +42 -0
  281. package/dist/src/utils/ast-grep-utils.js +140 -0
  282. package/dist/src/utils/ast-grep-utils.js.map +1 -0
  283. package/dist/src/utils/debugLogger.d.ts +11 -0
  284. package/dist/src/utils/debugLogger.js +16 -0
  285. package/dist/src/utils/debugLogger.js.map +1 -0
  286. package/dist/src/utils/diffOptions.d.ts +14 -0
  287. package/dist/src/utils/diffOptions.js +46 -0
  288. package/dist/src/utils/diffOptions.js.map +1 -0
  289. package/dist/src/utils/editor.d.ts +39 -0
  290. package/dist/src/utils/editor.js +212 -0
  291. package/dist/src/utils/editor.js.map +1 -0
  292. package/dist/src/utils/ensure-dirs.d.ts +10 -0
  293. package/dist/src/utils/ensure-dirs.js +16 -0
  294. package/dist/src/utils/ensure-dirs.js.map +1 -0
  295. package/dist/src/utils/errors.d.ts +59 -0
  296. package/dist/src/utils/errors.js +178 -0
  297. package/dist/src/utils/errors.js.map +1 -0
  298. package/dist/src/utils/fetch.d.ts +11 -0
  299. package/dist/src/utils/fetch.js +74 -0
  300. package/dist/src/utils/fetch.js.map +1 -0
  301. package/dist/src/utils/fileUtils.d.ts +32 -0
  302. package/dist/src/utils/fileUtils.js +363 -0
  303. package/dist/src/utils/fileUtils.js.map +1 -0
  304. package/dist/src/utils/fuzzy-replacer.d.ts +61 -0
  305. package/dist/src/utils/fuzzy-replacer.js +492 -0
  306. package/dist/src/utils/fuzzy-replacer.js.map +1 -0
  307. package/dist/src/utils/gitLineChanges.d.ts +12 -0
  308. package/dist/src/utils/gitLineChanges.js +171 -0
  309. package/dist/src/utils/gitLineChanges.js.map +1 -0
  310. package/dist/src/utils/gitUtils.d.ts +6 -0
  311. package/dist/src/utils/gitUtils.js +31 -0
  312. package/dist/src/utils/gitUtils.js.map +1 -0
  313. package/dist/src/utils/lsp-diagnostics-helper.d.ts +27 -0
  314. package/dist/src/utils/lsp-diagnostics-helper.js +62 -0
  315. package/dist/src/utils/lsp-diagnostics-helper.js.map +1 -0
  316. package/dist/src/utils/mediaUtils.d.ts +38 -0
  317. package/dist/src/utils/mediaUtils.js +22 -0
  318. package/dist/src/utils/mediaUtils.js.map +1 -0
  319. package/dist/src/utils/pathValidation.d.ts +7 -0
  320. package/dist/src/utils/pathValidation.js +39 -0
  321. package/dist/src/utils/pathValidation.js.map +1 -0
  322. package/dist/src/utils/paths.d.ts +7 -0
  323. package/dist/src/utils/paths.js +158 -0
  324. package/dist/src/utils/paths.js.map +1 -0
  325. package/dist/src/utils/resolveTextSearchTarget.d.ts +17 -0
  326. package/dist/src/utils/resolveTextSearchTarget.js +45 -0
  327. package/dist/src/utils/resolveTextSearchTarget.js.map +1 -0
  328. package/dist/src/utils/retry.d.ts +17 -0
  329. package/dist/src/utils/retry.js +185 -0
  330. package/dist/src/utils/retry.js.map +1 -0
  331. package/dist/src/utils/ripgrepPathResolver.d.ts +23 -0
  332. package/dist/src/utils/ripgrepPathResolver.js +179 -0
  333. package/dist/src/utils/ripgrepPathResolver.js.map +1 -0
  334. package/dist/src/utils/safeJsonStringify.d.ts +9 -0
  335. package/dist/src/utils/safeJsonStringify.js +21 -0
  336. package/dist/src/utils/safeJsonStringify.js.map +1 -0
  337. package/dist/src/utils/schemaValidator.d.ts +13 -0
  338. package/dist/src/utils/schemaValidator.js +275 -0
  339. package/dist/src/utils/schemaValidator.js.map +1 -0
  340. package/dist/src/utils/terminalSerializer.d.ts +33 -0
  341. package/dist/src/utils/terminalSerializer.js +6 -0
  342. package/dist/src/utils/terminalSerializer.js.map +1 -0
  343. package/dist/src/utils/todoContextTracker.d.ts +12 -0
  344. package/dist/src/utils/todoContextTracker.js +28 -0
  345. package/dist/src/utils/todoContextTracker.js.map +1 -0
  346. package/dist/src/utils/todoFormatter.d.ts +24 -0
  347. package/dist/src/utils/todoFormatter.js +157 -0
  348. package/dist/src/utils/todoFormatter.js.map +1 -0
  349. package/dist/src/utils/todoReminderService.d.ts +22 -0
  350. package/dist/src/utils/todoReminderService.js +43 -0
  351. package/dist/src/utils/todoReminderService.js.map +1 -0
  352. package/dist/src/utils/tool-key-storage-facade.d.ts +32 -0
  353. package/dist/src/utils/tool-key-storage-facade.js +56 -0
  354. package/dist/src/utils/tool-key-storage-facade.js.map +1 -0
  355. package/dist/src/utils/tool-key-storage-types.d.ts +56 -0
  356. package/dist/src/utils/tool-key-storage-types.js +56 -0
  357. package/dist/src/utils/tool-key-storage-types.js.map +1 -0
  358. package/dist/src/utils/toolOutputLimiter.d.ts +29 -0
  359. package/dist/src/utils/toolOutputLimiter.js +107 -0
  360. package/dist/src/utils/toolOutputLimiter.js.map +1 -0
  361. package/dist/src/utils/unicodeUtils.d.ts +55 -0
  362. package/dist/src/utils/unicodeUtils.js +129 -0
  363. package/dist/src/utils/unicodeUtils.js.map +1 -0
  364. package/package.json +75 -0
@@ -0,0 +1,417 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, } from './tools.js';
7
+ import { GOOGLE_WEB_FETCH_TOOL } from '../types/tool-names.js';
8
+ import { ToolErrorType } from '../types/tool-error.js';
9
+ import { getErrorMessage } from '../utils/errors.js';
10
+ import { fetchWithTimeout, isPrivateIp } from '../utils/fetch.js';
11
+ import { convert } from 'html-to-text';
12
+ import { debugLogger as logger } from '../utils/debugLogger.js';
13
+ const URL_FETCH_TIMEOUT_MS = 10000;
14
+ const MAX_CONTENT_LENGTH = 100000;
15
+ /**
16
+ * Parses a prompt to extract valid URLs and identify malformed ones.
17
+ * Strips common trailing punctuation from tokens before URL validation.
18
+ */
19
+ export function parsePrompt(text) {
20
+ const tokens = text.split(/\s+/);
21
+ const validUrls = [];
22
+ const errors = [];
23
+ const stripTrailingPunctuation = (input) => {
24
+ let endIndex = input.length;
25
+ // eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
26
+ while (endIndex > 0) {
27
+ const lastChar = input[endIndex - 1];
28
+ if (
29
+ // eslint-disable-next-line sonarjs/expression-complexity -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
30
+ lastChar === '.' ||
31
+ lastChar === ',' ||
32
+ lastChar === ';' ||
33
+ lastChar === ':' ||
34
+ lastChar === '!' ||
35
+ lastChar === '?') {
36
+ endIndex--;
37
+ continue;
38
+ }
39
+ break;
40
+ }
41
+ return input.slice(0, endIndex);
42
+ };
43
+ for (const token of tokens) {
44
+ if (!token)
45
+ continue;
46
+ // Heuristic to check if the token appears to contain URL-like chars.
47
+ if (token.includes('://')) {
48
+ // Strip common trailing punctuation (period, comma, semicolon, colon, etc.)
49
+ // This handles natural language like "Check https://example.com."
50
+ const cleaned = stripTrailingPunctuation(token);
51
+ try {
52
+ // Validate with new URL()
53
+ const url = new URL(cleaned);
54
+ // Allowlist protocols
55
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
56
+ if (['http:', 'https:'].includes(url.protocol)) {
57
+ validUrls.push(url.href);
58
+ }
59
+ else {
60
+ errors.push(`Unsupported protocol in URL: "${cleaned}". Only http and https are supported.`);
61
+ }
62
+ }
63
+ catch {
64
+ // Malformed URL according to WHATWG standard.
65
+ errors.push(`Malformed URL detected: "${cleaned}".`);
66
+ }
67
+ }
68
+ }
69
+ return { validUrls, errors };
70
+ }
71
+ function getResponseText(response) {
72
+ const parts = response.candidates?.[0]?.content?.parts;
73
+ if (!parts) {
74
+ return undefined;
75
+ }
76
+ const textSegments = parts
77
+ .map((part) => part.text)
78
+ .filter((text) => typeof text === 'string');
79
+ return textSegments.length > 0 ? textSegments.join('') : undefined;
80
+ }
81
+ class GoogleWebFetchToolInvocation extends BaseToolInvocation {
82
+ host;
83
+ constructor(host, params, messageBus, toolName, displayName) {
84
+ super(params, messageBus, toolName, displayName);
85
+ this.host = host;
86
+ }
87
+ getToolName() {
88
+ return GoogleWebFetchTool.Name;
89
+ }
90
+ async executeFallback(_signal) {
91
+ const { validUrls: urls } = parsePrompt(this.params.prompt);
92
+ // For now, we only support one URL for fallback
93
+ let url = urls[0];
94
+ // Convert GitHub blob URL to raw URL
95
+ // Convert GitHub blob URL to raw URL
96
+ try {
97
+ const urlObj = new URL(url);
98
+ if (urlObj.hostname === 'github.com' && url.includes('/blob/')) {
99
+ url = url
100
+ .replace('github.com', 'raw.githubusercontent.com')
101
+ .replace('/blob/', '/');
102
+ }
103
+ }
104
+ catch {
105
+ // Invalid URL; fetchWithTimeout will handle the error.
106
+ }
107
+ try {
108
+ const response = await fetchWithTimeout(url, URL_FETCH_TIMEOUT_MS, _signal);
109
+ if (!response.ok) {
110
+ throw new Error(`Request failed with status code ${response.status} ${response.statusText}`);
111
+ }
112
+ const rawContent = await response.text();
113
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: get() returns string | null, empty string should fall through
114
+ const contentType = response.headers.get('content-type') || '';
115
+ let textContent;
116
+ // Only use html-to-text if content type is HTML, or if no content type is provided (assume HTML)
117
+ if (contentType.toLowerCase().includes('text/html') ||
118
+ contentType === '') {
119
+ textContent = convert(rawContent, {
120
+ wordwrap: false,
121
+ selectors: [
122
+ { selector: 'a', options: { ignoreHref: true } },
123
+ { selector: 'img', format: 'skip' },
124
+ ],
125
+ });
126
+ }
127
+ else {
128
+ // For other content types (text/plain, application/json, etc.), use raw text
129
+ textContent = rawContent;
130
+ }
131
+ textContent = textContent.substring(0, MAX_CONTENT_LENGTH);
132
+ // For private URLs in llxprt, we return raw content without AI processing
133
+ // This preserves our multi-provider approach
134
+ return {
135
+ llmContent: textContent,
136
+ returnDisplay: `Content for ${url} fetched directly.`,
137
+ };
138
+ }
139
+ catch (e) {
140
+ const error = e;
141
+ const errorMessage = `Error during fallback fetch for ${url}: ${error.message}`;
142
+ return {
143
+ llmContent: `Error: ${errorMessage}`,
144
+ returnDisplay: `Error: ${errorMessage}`,
145
+ error: {
146
+ message: errorMessage,
147
+ type: ToolErrorType.WEB_FETCH_FALLBACK_FAILED,
148
+ },
149
+ };
150
+ }
151
+ }
152
+ getDescription() {
153
+ const displayPrompt = this.params.prompt.length > 100
154
+ ? this.params.prompt.substring(0, 97) + '...'
155
+ : this.params.prompt;
156
+ return `Processing URLs and instructions from prompt: "${displayPrompt}"`;
157
+ }
158
+ async shouldConfirmExecute(abortSignal) {
159
+ // Try policy/message bus first when available.
160
+ if (this.messageBus) {
161
+ const decision = await this.getMessageBusDecision(abortSignal);
162
+ if (decision === 'ALLOW') {
163
+ return false;
164
+ }
165
+ if (decision === 'DENY') {
166
+ throw new Error('Tool execution denied by policy.');
167
+ }
168
+ // if 'ASK_USER', fall through to legacy confirmation UI
169
+ }
170
+ if (this.host.getApprovalMode() === 'auto') {
171
+ return false;
172
+ }
173
+ // Perform GitHub URL conversion here to differentiate between user-provided
174
+ // URL and the actual URL to be fetched.
175
+ const { validUrls } = parsePrompt(this.params.prompt);
176
+ const urls = validUrls.map((url) => {
177
+ try {
178
+ const urlObj = new URL(url);
179
+ if (urlObj.hostname === 'github.com' && url.includes('/blob/')) {
180
+ return url
181
+ .replace('github.com', 'raw.githubusercontent.com')
182
+ .replace('/blob/', '/');
183
+ }
184
+ }
185
+ catch {
186
+ // Invalid URL; return as-is for error handling downstream.
187
+ }
188
+ return url;
189
+ });
190
+ const confirmationDetails = {
191
+ type: 'info',
192
+ title: `Confirm Web Fetch`,
193
+ prompt: this.params.prompt,
194
+ urls,
195
+ onConfirm: async (outcome) => {
196
+ if (outcome === ToolConfirmationOutcome.ProceedAlways) {
197
+ // No need to publish a policy update as the default policy for
198
+ // AUTO_EDIT already reflects always approving web-fetch.
199
+ this.host.setApprovalMode('auto');
200
+ }
201
+ else {
202
+ await this.publishPolicyUpdate(outcome);
203
+ }
204
+ },
205
+ };
206
+ return confirmationDetails;
207
+ }
208
+ async execute(signal) {
209
+ const userPrompt = this.params.prompt;
210
+ const { validUrls: urls } = parsePrompt(userPrompt);
211
+ const url = urls[0];
212
+ if (isPrivateIp(url))
213
+ return this.executePrivateUrlFallback(signal, url);
214
+ const serverToolsProvider = this.getServerToolsProvider();
215
+ if (serverToolsProvider instanceof Error) {
216
+ return this.createProviderErrorResult(serverToolsProvider.message);
217
+ }
218
+ try {
219
+ const response = await this.invokeWebFetch(serverToolsProvider, userPrompt, signal);
220
+ return await this.formatServerResponse(response, userPrompt, signal, url);
221
+ }
222
+ catch (error) {
223
+ return this.createProcessingErrorResult(error);
224
+ }
225
+ }
226
+ async executePrivateUrlFallback(signal, url) {
227
+ const errorMessage = 'Private/local URLs cannot be processed with AI analysis. Processing content directly.';
228
+ const result = await this.executeFallback(signal);
229
+ return {
230
+ ...result,
231
+ llmContent: `${errorMessage}\n\nContent from ${url}:\n\n${result.llmContent}`,
232
+ };
233
+ }
234
+ getServerToolsProvider() {
235
+ const serverToolsProvider = this.host.getServerToolsProvider?.();
236
+ if (!serverToolsProvider) {
237
+ return new Error(this.host.hasProviderManager?.() === false ? 'provider' : 'gemini');
238
+ }
239
+ const supportedTools = serverToolsProvider.getServerTools();
240
+ if (!supportedTools.includes(GOOGLE_WEB_FETCH_TOOL)) {
241
+ return new Error('unsupported');
242
+ }
243
+ return serverToolsProvider;
244
+ }
245
+ createProviderErrorResult(message) {
246
+ if (message === 'provider')
247
+ return this.createMissingProviderResult();
248
+ if (message === 'gemini')
249
+ return this.createMissingGeminiResult();
250
+ return this.createUnsupportedServerToolResult();
251
+ }
252
+ createMissingProviderResult() {
253
+ return {
254
+ llmContent: 'Web fetch requires a provider. Please use --provider gemini with authentication.',
255
+ returnDisplay: 'Web fetch requires a provider.',
256
+ error: {
257
+ message: 'No provider manager available',
258
+ type: ToolErrorType.WEB_FETCH_PROCESSING_ERROR,
259
+ },
260
+ };
261
+ }
262
+ createMissingGeminiResult() {
263
+ return {
264
+ llmContent: 'Web fetch requires Gemini provider to be configured. Please ensure Gemini is available with authentication.',
265
+ returnDisplay: 'Web fetch requires Gemini provider.',
266
+ error: {
267
+ message: 'No server tools provider available',
268
+ type: ToolErrorType.WEB_FETCH_PROCESSING_ERROR,
269
+ },
270
+ };
271
+ }
272
+ createUnsupportedServerToolResult() {
273
+ return {
274
+ llmContent: 'Web fetch is not available. The server tools provider does not support web fetch.',
275
+ returnDisplay: 'Web fetch not available.',
276
+ error: {
277
+ message: 'Server tools provider does not support web_fetch',
278
+ type: ToolErrorType.WEB_FETCH_PROCESSING_ERROR,
279
+ },
280
+ };
281
+ }
282
+ async invokeWebFetch(serverToolsProvider, userPrompt, signal) {
283
+ const response = await serverToolsProvider.invokeServerTool('web_fetch', { prompt: userPrompt }, { signal });
284
+ logger.log(`Full response for prompt "${userPrompt.substring(0, 50)}...":`, JSON.stringify(response, null, 2));
285
+ return response;
286
+ }
287
+ async formatServerResponse(response, userPrompt, signal, url) {
288
+ const typedResponse = response;
289
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: getResponseText returns string | null | undefined, empty string should fall through
290
+ let responseText = getResponseText(typedResponse) || '';
291
+ const groundingMetadata = typedResponse.candidates?.[0]?.groundingMetadata;
292
+ const sources = groundingMetadata?.groundingChunks;
293
+ const groundingSupports = groundingMetadata?.groundingSupports;
294
+ if (this.hasProcessingError(typedResponse, responseText, sources)) {
295
+ if (isPrivateIp(url))
296
+ return this.executeFallback(signal);
297
+ return {
298
+ llmContent: 'No content found or URL retrieval failed.',
299
+ returnDisplay: 'No content found.',
300
+ };
301
+ }
302
+ responseText = this.addSourcesToResponse(responseText, sources, groundingSupports);
303
+ logger.log(`Formatted tool response for prompt "${userPrompt}:\n\n":`, responseText);
304
+ return {
305
+ llmContent: responseText,
306
+ returnDisplay: responseText,
307
+ };
308
+ }
309
+ hasProcessingError(response, responseText, sources) {
310
+ const urlMetadata = response.candidates?.[0]?.urlContextMetadata?.urlMetadata;
311
+ if (urlMetadata !== undefined && urlMetadata.length > 0) {
312
+ return urlMetadata.every((metadata) =>
313
+ // eslint-disable-next-line sonarjs/different-types-comparison -- Generated Gemini enum typing is narrower than runtime URL retrieval statuses; preserve the original success-status comparison.
314
+ metadata.urlRetrievalStatus !== 'URL_RETRIEVAL_STATUS_SUCCESS');
315
+ }
316
+ if (responseText.trim())
317
+ return false;
318
+ return sources === undefined || sources.length === 0;
319
+ }
320
+ addSourcesToResponse(responseText, sources, groundingSupports) {
321
+ if (sources === undefined || sources.length === 0)
322
+ return responseText;
323
+ let updatedText = this.insertCitationMarkers(responseText, groundingSupports);
324
+ const sourceListFormatted = this.formatSources(sources);
325
+ if (sourceListFormatted.length > 0) {
326
+ updatedText += `\n\nSources:\n${sourceListFormatted.join('\n')}`;
327
+ }
328
+ return updatedText;
329
+ }
330
+ formatSources(sources) {
331
+ return sources.map((source, index) => {
332
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: title is optional string, empty string should fall through
333
+ const title = source.web?.title || 'Untitled';
334
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: uri is optional string, empty string should fall through
335
+ const uri = source.web?.uri || 'Unknown URI';
336
+ return `[${index + 1}] ${title} (${uri})`;
337
+ });
338
+ }
339
+ insertCitationMarkers(responseText, groundingSupports) {
340
+ if (groundingSupports === undefined || groundingSupports.length === 0) {
341
+ return responseText;
342
+ }
343
+ const insertions = this.getCitationInsertions(groundingSupports);
344
+ const responseChars = responseText.split('');
345
+ for (const insertion of insertions) {
346
+ responseChars.splice(insertion.index, 0, insertion.marker);
347
+ }
348
+ return responseChars.join('');
349
+ }
350
+ getCitationInsertions(groundingSupports) {
351
+ const insertions = [];
352
+ for (const support of groundingSupports) {
353
+ if (!support.segment || !support.groundingChunkIndices)
354
+ continue;
355
+ const citationMarker = support.groundingChunkIndices
356
+ .map((chunkIndex) => `[${chunkIndex + 1}]`)
357
+ .join('');
358
+ insertions.push({
359
+ index: support.segment.endIndex,
360
+ marker: citationMarker,
361
+ });
362
+ }
363
+ return insertions.sort((a, b) => b.index - a.index);
364
+ }
365
+ createProcessingErrorResult(error) {
366
+ const errorMessage = `Error during web fetch: ${getErrorMessage(error)}`;
367
+ logger.error(errorMessage, error);
368
+ return {
369
+ llmContent: `Error: ${errorMessage}`,
370
+ returnDisplay: `Error: ${errorMessage}`,
371
+ error: {
372
+ message: errorMessage,
373
+ type: ToolErrorType.WEB_FETCH_PROCESSING_ERROR,
374
+ },
375
+ };
376
+ }
377
+ }
378
+ /**
379
+ * Implementation of the WebFetch tool logic
380
+ */
381
+ export class GoogleWebFetchTool extends BaseDeclarativeTool {
382
+ host;
383
+ static Name = 'google_web_fetch';
384
+ constructor(host, messageBus) {
385
+ super(GoogleWebFetchTool.Name, 'GoogleWebFetch', "Processes content from URL(s), including local and private network addresses (e.g., localhost), embedded in a prompt. Include up to 20 URLs and instructions (e.g., summarize, extract specific data) directly in the 'prompt' parameter.", Kind.Fetch, {
386
+ properties: {
387
+ prompt: {
388
+ description: 'A comprehensive prompt that includes the URL(s) (up to 20) to fetch and specific instructions on how to process their content (e.g., "Summarize https://example.com/article and extract key points from https://another.com/data"). All URLs to be fetched must be valid and complete, starting with "http://" or "https://", and be fully-formed with a valid hostname (e.g., a domain name like "example.com" or an IP address). For example, "https://example.com" is valid, but "example.com" is not.',
389
+ type: 'string',
390
+ },
391
+ },
392
+ required: ['prompt'],
393
+ type: 'object',
394
+ }, false, // output is not markdown
395
+ false, // output cannot be updated
396
+ messageBus);
397
+ this.host = host;
398
+ // Proxy is now set globally in Config constructor with error handling
399
+ }
400
+ validateToolParamValues(params) {
401
+ if (!params.prompt || params.prompt.trim() === '') {
402
+ return "The 'prompt' parameter cannot be empty and must contain URL(s) and instructions.";
403
+ }
404
+ const { validUrls, errors } = parsePrompt(params.prompt);
405
+ if (errors.length > 0) {
406
+ return `Error(s) in prompt URLs:\n- ${errors.join('\n- ')}`;
407
+ }
408
+ if (validUrls.length === 0) {
409
+ return "The 'prompt' must contain at least one valid URL (starting with http:// or https://).";
410
+ }
411
+ return null;
412
+ }
413
+ createInvocation(params, messageBus, toolName, displayName) {
414
+ return new GoogleWebFetchToolInvocation(this.host, params, messageBus, toolName ?? this.name, displayName ?? this.displayName);
415
+ }
416
+ }
417
+ //# sourceMappingURL=google-web-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-web-fetch.js","sourceRoot":"","sources":["../../../src/tools/google-web-fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,IAAI,EAEJ,uBAAuB,GAGxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,oBAAoB,GAAG,KAAK,CAAC;AACnC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IAItC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,MAAM,wBAAwB,GAAG,CAAC,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,KAAK,EAAE,EAAE,CAAC;YAClD,OAAO,kFAAkF,CAAC;QAC5F,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEzD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,+BAA+B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9D,CAAC;QAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,uFAAuF,CAAC;QACjG,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAES,gBAAgB,CACxB,MAAgC,EAChC,UAA2B,EAC3B,QAAiB,EACjB,WAAoB;QAEpB,OAAO,IAAI,4BAA4B,CACrC,IAAI,CAAC,IAAI,EACT,MAAM,EACN,UAAU,EACV,QAAQ,IAAI,IAAI,CAAC,IAAI,EACrB,WAAW,IAAI,IAAI,CAAC,WAAW,CAChC,CAAC;IACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { GroundingMetadata } from '@google/genai';
7
+ import type { IWebSearchService } from '../interfaces/index.js';
8
+ import { BaseToolInvocation, type ToolResult } from './tools.js';
9
+ export interface GroundingChunkWeb {
10
+ uri?: string;
11
+ title?: string;
12
+ }
13
+ export interface GroundingChunkItem {
14
+ web?: GroundingChunkWeb;
15
+ }
16
+ export interface GroundingSupportSegment {
17
+ startIndex: number;
18
+ endIndex: number;
19
+ text?: string;
20
+ }
21
+ export interface GroundingSupportItem {
22
+ segment?: GroundingSupportSegment;
23
+ groundingChunkIndices?: number[];
24
+ confidenceScores?: number[];
25
+ }
26
+ export interface WebSearchToolParams {
27
+ query: string;
28
+ }
29
+ export interface WebSearchToolResult extends ToolResult {
30
+ sources?: GroundingMetadata extends {
31
+ groundingChunks: GroundingChunkItem[];
32
+ } ? GroundingMetadata['groundingChunks'] : GroundingChunkItem[];
33
+ }
34
+ export declare class GoogleWebSearchToolInvocation extends BaseToolInvocation<WebSearchToolParams, WebSearchToolResult> {
35
+ private readonly webSearchService;
36
+ constructor(webSearchService: IWebSearchService, params: WebSearchToolParams, messageBus?: import('../interfaces/index.js').IToolMessageBus);
37
+ getToolName(): string;
38
+ getDescription(): string;
39
+ execute(signal: AbortSignal): Promise<WebSearchToolResult>;
40
+ private validateQuery;
41
+ private createEmptyQueryResult;
42
+ private getServerToolsProvider;
43
+ private createProviderErrorResult;
44
+ private createMissingProviderResult;
45
+ private createMissingGeminiResult;
46
+ private createUnsupportedServerToolResult;
47
+ private formatSearchResponse;
48
+ private addSourcesToResponse;
49
+ private formatSources;
50
+ private insertCitationMarkers;
51
+ private getCitationInsertions;
52
+ private createSearchErrorResult;
53
+ }
@@ -0,0 +1,180 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { GOOGLE_WEB_SEARCH_TOOL } from '../types/tool-names.js';
7
+ import { ToolErrorType } from '../types/tool-error.js';
8
+ import { getErrorMessage } from '../utils/errors.js';
9
+ import { BaseToolInvocation } from './tools.js';
10
+ export class GoogleWebSearchToolInvocation extends BaseToolInvocation {
11
+ webSearchService;
12
+ constructor(webSearchService, params, messageBus) {
13
+ super(params, messageBus);
14
+ this.webSearchService = webSearchService;
15
+ }
16
+ getToolName() {
17
+ return GOOGLE_WEB_SEARCH_TOOL;
18
+ }
19
+ getDescription() {
20
+ return `Searching the web for: "${this.params.query}"`;
21
+ }
22
+ async execute(signal) {
23
+ const invalidQueryResult = this.validateQuery();
24
+ if (invalidQueryResult)
25
+ return invalidQueryResult;
26
+ try {
27
+ const serverToolsProvider = this.getServerToolsProvider();
28
+ if (serverToolsProvider instanceof Error) {
29
+ return this.createProviderErrorResult(serverToolsProvider.message);
30
+ }
31
+ const searchQuery = this.params.query.trim();
32
+ if (searchQuery === '')
33
+ return this.createEmptyQueryResult();
34
+ const response = await serverToolsProvider.invokeServerTool('web_search', { query: searchQuery }, { signal });
35
+ return this.formatSearchResponse(response);
36
+ }
37
+ catch (error) {
38
+ return this.createSearchErrorResult(error);
39
+ }
40
+ }
41
+ validateQuery() {
42
+ if (!this.params.query ||
43
+ this.params.query.trim() === '' ||
44
+ this.params.query === 'undefined') {
45
+ return {
46
+ llmContent: `Error: Web search requires a valid search query. Please provide a specific search query.`,
47
+ returnDisplay: `Error: No valid search query provided.`,
48
+ };
49
+ }
50
+ return undefined;
51
+ }
52
+ createEmptyQueryResult() {
53
+ return {
54
+ llmContent: `Error: Cannot perform web search without a query.`,
55
+ returnDisplay: `Error: Empty search query.`,
56
+ };
57
+ }
58
+ getServerToolsProvider() {
59
+ const serverToolsProvider = this.webSearchService.getServerToolsProvider();
60
+ if (!serverToolsProvider)
61
+ return new Error('gemini');
62
+ const serverTools = serverToolsProvider.getServerTools();
63
+ if (!serverTools.includes('web_search'))
64
+ return new Error('unsupported');
65
+ return serverToolsProvider;
66
+ }
67
+ createProviderErrorResult(message) {
68
+ if (message === 'provider')
69
+ return this.createMissingProviderResult();
70
+ if (message === 'gemini')
71
+ return this.createMissingGeminiResult();
72
+ return this.createUnsupportedServerToolResult();
73
+ }
74
+ createMissingProviderResult() {
75
+ return {
76
+ llmContent: `Web search requires a provider. Please use --provider gemini with authentication.`,
77
+ returnDisplay: 'Web search requires a provider.',
78
+ };
79
+ }
80
+ createMissingGeminiResult() {
81
+ return {
82
+ llmContent: `Web search requires Gemini provider to be configured. Please ensure Gemini is available with authentication.`,
83
+ returnDisplay: 'Web search requires Gemini provider.',
84
+ };
85
+ }
86
+ createUnsupportedServerToolResult() {
87
+ return {
88
+ llmContent: `Web search is not available. The server tools provider does not support web search.`,
89
+ returnDisplay: `Web search not available.`,
90
+ };
91
+ }
92
+ formatSearchResponse(response) {
93
+ const geminiResponse = response;
94
+ const responseText = getResponseText(geminiResponse);
95
+ const groundingMetadata = geminiResponse.candidates?.[0]?.groundingMetadata;
96
+ const sources = groundingMetadata?.groundingChunks;
97
+ const groundingSupports = groundingMetadata?.groundingSupports;
98
+ if (!responseText?.trim()) {
99
+ return {
100
+ llmContent: `No search results or information found for query: "${this.params.query}"`,
101
+ returnDisplay: 'No information found.',
102
+ };
103
+ }
104
+ const modifiedResponseText = this.addSourcesToResponse(responseText, sources, groundingSupports);
105
+ return {
106
+ llmContent: `Web search results for "${this.params.query}":\n\n${modifiedResponseText}`,
107
+ returnDisplay: `Search results for "${this.params.query}" returned.`,
108
+ sources,
109
+ };
110
+ }
111
+ addSourcesToResponse(responseText, sources, groundingSupports) {
112
+ if (sources === undefined || sources.length === 0)
113
+ return responseText;
114
+ let modifiedResponseText = this.insertCitationMarkers(responseText, groundingSupports);
115
+ const sourceListFormatted = this.formatSources(sources);
116
+ if (sourceListFormatted.length > 0) {
117
+ modifiedResponseText += '\n\nSources:\n' + sourceListFormatted.join('\n');
118
+ }
119
+ return modifiedResponseText;
120
+ }
121
+ formatSources(sources) {
122
+ return sources.map((source, index) => {
123
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: empty title should show 'Untitled'
124
+ const title = source.web?.title || 'Untitled';
125
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: empty URI should show 'No URI'
126
+ const uri = source.web?.uri || 'No URI';
127
+ return `[${index + 1}] ${title} (${uri})`;
128
+ });
129
+ }
130
+ insertCitationMarkers(responseText, groundingSupports) {
131
+ if (groundingSupports === undefined || groundingSupports.length === 0) {
132
+ return responseText;
133
+ }
134
+ const textBuffer = Buffer.from(responseText, 'utf-8');
135
+ const insertions = this.getCitationInsertions(groundingSupports, textBuffer);
136
+ const responseChars = responseText.split('');
137
+ for (const insertion of insertions) {
138
+ responseChars.splice(insertion.index, 0, insertion.marker);
139
+ }
140
+ return responseChars.join('');
141
+ }
142
+ getCitationInsertions(groundingSupports, textBuffer) {
143
+ const insertions = [];
144
+ for (const support of groundingSupports) {
145
+ if (!support.segment || !support.groundingChunkIndices)
146
+ continue;
147
+ const citationMarker = support.groundingChunkIndices
148
+ .map((chunkIndex) => `[${chunkIndex + 1}]`)
149
+ .join('');
150
+ const charIndex = textBuffer
151
+ .subarray(0, support.segment.endIndex)
152
+ .toString('utf-8').length;
153
+ insertions.push({ index: charIndex, marker: citationMarker });
154
+ }
155
+ return insertions.sort((a, b) => b.index - a.index);
156
+ }
157
+ createSearchErrorResult(error) {
158
+ const queryDisplay = this.params.query || 'undefined';
159
+ const errorMessage = `Error during web search for query "${queryDisplay}": ${getErrorMessage(error)}`;
160
+ return {
161
+ llmContent: `Error: ${errorMessage}`,
162
+ returnDisplay: `Error performing web search.`,
163
+ error: {
164
+ type: ToolErrorType.WEB_SEARCH_FAILED,
165
+ message: `Web search failed: ${getErrorMessage(error)}`,
166
+ },
167
+ };
168
+ }
169
+ }
170
+ function getResponseText(response) {
171
+ const parts = response.candidates?.[0]?.content?.parts;
172
+ if (!parts)
173
+ return undefined;
174
+ const textSegments = parts
175
+ .filter((part) => part.thought !== true && part.thoughtSignature === undefined)
176
+ .map((part) => part.text)
177
+ .filter((text) => typeof text === 'string');
178
+ return textSegments.length > 0 ? textSegments.join('') : undefined;
179
+ }
180
+ //# sourceMappingURL=google-web-search-invocation.js.map