@office-ai/aioncli-core 0.1.1-8.1

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 (564) hide show
  1. package/dist/.last_build +0 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +8 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/__mocks__/fs/promises.d.ts +11 -0
  6. package/dist/src/__mocks__/fs/promises.js +17 -0
  7. package/dist/src/__mocks__/fs/promises.js.map +1 -0
  8. package/dist/src/code_assist/codeAssist.d.ts +9 -0
  9. package/dist/src/code_assist/codeAssist.js +19 -0
  10. package/dist/src/code_assist/codeAssist.js.map +1 -0
  11. package/dist/src/code_assist/converter.d.ts +70 -0
  12. package/dist/src/code_assist/converter.js +126 -0
  13. package/dist/src/code_assist/converter.js.map +1 -0
  14. package/dist/src/code_assist/converter.test.d.ts +6 -0
  15. package/dist/src/code_assist/converter.test.js +279 -0
  16. package/dist/src/code_assist/converter.test.js.map +1 -0
  17. package/dist/src/code_assist/oauth2.d.ts +24 -0
  18. package/dist/src/code_assist/oauth2.js +373 -0
  19. package/dist/src/code_assist/oauth2.js.map +1 -0
  20. package/dist/src/code_assist/oauth2.test.d.ts +6 -0
  21. package/dist/src/code_assist/oauth2.test.js +334 -0
  22. package/dist/src/code_assist/oauth2.test.js.map +1 -0
  23. package/dist/src/code_assist/server.d.ts +37 -0
  24. package/dist/src/code_assist/server.js +125 -0
  25. package/dist/src/code_assist/server.js.map +1 -0
  26. package/dist/src/code_assist/server.test.d.ts +6 -0
  27. package/dist/src/code_assist/server.test.js +134 -0
  28. package/dist/src/code_assist/server.test.js.map +1 -0
  29. package/dist/src/code_assist/setup.d.ts +20 -0
  30. package/dist/src/code_assist/setup.js +70 -0
  31. package/dist/src/code_assist/setup.js.map +1 -0
  32. package/dist/src/code_assist/setup.test.d.ts +6 -0
  33. package/dist/src/code_assist/setup.test.js +65 -0
  34. package/dist/src/code_assist/setup.test.js.map +1 -0
  35. package/dist/src/code_assist/types.d.ts +148 -0
  36. package/dist/src/code_assist/types.js +46 -0
  37. package/dist/src/code_assist/types.js.map +1 -0
  38. package/dist/src/config/config.d.ts +272 -0
  39. package/dist/src/config/config.js +554 -0
  40. package/dist/src/config/config.js.map +1 -0
  41. package/dist/src/config/config.test.d.ts +6 -0
  42. package/dist/src/config/config.test.js +365 -0
  43. package/dist/src/config/config.test.js.map +1 -0
  44. package/dist/src/config/flashFallback.test.d.ts +6 -0
  45. package/dist/src/config/flashFallback.test.js +87 -0
  46. package/dist/src/config/flashFallback.test.js.map +1 -0
  47. package/dist/src/config/models.d.ts +9 -0
  48. package/dist/src/config/models.js +10 -0
  49. package/dist/src/config/models.js.map +1 -0
  50. package/dist/src/core/client.d.ts +61 -0
  51. package/dist/src/core/client.js +485 -0
  52. package/dist/src/core/client.js.map +1 -0
  53. package/dist/src/core/client.test.d.ts +6 -0
  54. package/dist/src/core/client.test.js +1008 -0
  55. package/dist/src/core/client.test.js.map +1 -0
  56. package/dist/src/core/contentGenerator.d.ts +45 -0
  57. package/dist/src/core/contentGenerator.js +85 -0
  58. package/dist/src/core/contentGenerator.js.map +1 -0
  59. package/dist/src/core/contentGenerator.test.d.ts +6 -0
  60. package/dist/src/core/contentGenerator.test.js +100 -0
  61. package/dist/src/core/contentGenerator.test.js.map +1 -0
  62. package/dist/src/core/coreToolScheduler.d.ts +117 -0
  63. package/dist/src/core/coreToolScheduler.js +530 -0
  64. package/dist/src/core/coreToolScheduler.js.map +1 -0
  65. package/dist/src/core/coreToolScheduler.test.d.ts +6 -0
  66. package/dist/src/core/coreToolScheduler.test.js +625 -0
  67. package/dist/src/core/coreToolScheduler.test.js.map +1 -0
  68. package/dist/src/core/geminiChat.d.ts +118 -0
  69. package/dist/src/core/geminiChat.js +509 -0
  70. package/dist/src/core/geminiChat.js.map +1 -0
  71. package/dist/src/core/geminiChat.test.d.ts +6 -0
  72. package/dist/src/core/geminiChat.test.js +424 -0
  73. package/dist/src/core/geminiChat.test.js.map +1 -0
  74. package/dist/src/core/geminiRequest.d.ts +13 -0
  75. package/dist/src/core/geminiRequest.js +10 -0
  76. package/dist/src/core/geminiRequest.js.map +1 -0
  77. package/dist/src/core/logger.d.ts +37 -0
  78. package/dist/src/core/logger.js +273 -0
  79. package/dist/src/core/logger.js.map +1 -0
  80. package/dist/src/core/logger.test.d.ts +6 -0
  81. package/dist/src/core/logger.test.js +467 -0
  82. package/dist/src/core/logger.test.js.map +1 -0
  83. package/dist/src/core/loggingContentGenerator.d.ts +24 -0
  84. package/dist/src/core/loggingContentGenerator.js +89 -0
  85. package/dist/src/core/loggingContentGenerator.js.map +1 -0
  86. package/dist/src/core/modelCheck.d.ts +14 -0
  87. package/dist/src/core/modelCheck.js +62 -0
  88. package/dist/src/core/modelCheck.js.map +1 -0
  89. package/dist/src/core/nonInteractiveToolExecutor.d.ts +12 -0
  90. package/dist/src/core/nonInteractiveToolExecutor.js +124 -0
  91. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
  92. package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +6 -0
  93. package/dist/src/core/nonInteractiveToolExecutor.test.js +165 -0
  94. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
  95. package/dist/src/core/openaiContentGenerator.d.ts +77 -0
  96. package/dist/src/core/openaiContentGenerator.js +1395 -0
  97. package/dist/src/core/openaiContentGenerator.js.map +1 -0
  98. package/dist/src/core/openaiContentGenerator.test.d.ts +6 -0
  99. package/dist/src/core/openaiContentGenerator.test.js +1904 -0
  100. package/dist/src/core/openaiContentGenerator.test.js.map +1 -0
  101. package/dist/src/core/prompts.d.ts +12 -0
  102. package/dist/src/core/prompts.js +359 -0
  103. package/dist/src/core/prompts.js.map +1 -0
  104. package/dist/src/core/prompts.test.d.ts +6 -0
  105. package/dist/src/core/prompts.test.js +214 -0
  106. package/dist/src/core/prompts.test.js.map +1 -0
  107. package/dist/src/core/subagent.d.ts +230 -0
  108. package/dist/src/core/subagent.js +447 -0
  109. package/dist/src/core/subagent.js.map +1 -0
  110. package/dist/src/core/subagent.test.d.ts +6 -0
  111. package/dist/src/core/subagent.test.js +515 -0
  112. package/dist/src/core/subagent.test.js.map +1 -0
  113. package/dist/src/core/tokenLimits.d.ts +10 -0
  114. package/dist/src/core/tokenLimits.js +28 -0
  115. package/dist/src/core/tokenLimits.js.map +1 -0
  116. package/dist/src/core/turn.d.ts +114 -0
  117. package/dist/src/core/turn.js +143 -0
  118. package/dist/src/core/turn.js.map +1 -0
  119. package/dist/src/core/turn.test.d.ts +6 -0
  120. package/dist/src/core/turn.test.js +369 -0
  121. package/dist/src/core/turn.test.js.map +1 -0
  122. package/dist/src/ide/detect-ide.d.ts +10 -0
  123. package/dist/src/ide/detect-ide.js +27 -0
  124. package/dist/src/ide/detect-ide.js.map +1 -0
  125. package/dist/src/ide/ide-client.d.ts +56 -0
  126. package/dist/src/ide/ide-client.js +268 -0
  127. package/dist/src/ide/ide-client.js.map +1 -0
  128. package/dist/src/ide/ide-installer.d.ts +14 -0
  129. package/dist/src/ide/ide-installer.js +109 -0
  130. package/dist/src/ide/ide-installer.js.map +1 -0
  131. package/dist/src/ide/ide-installer.test.d.ts +6 -0
  132. package/dist/src/ide/ide-installer.test.js +55 -0
  133. package/dist/src/ide/ide-installer.test.js.map +1 -0
  134. package/dist/src/ide/ideContext.d.ts +374 -0
  135. package/dist/src/ide/ideContext.js +147 -0
  136. package/dist/src/ide/ideContext.js.map +1 -0
  137. package/dist/src/ide/ideContext.test.d.ts +6 -0
  138. package/dist/src/ide/ideContext.test.js +265 -0
  139. package/dist/src/ide/ideContext.test.js.map +1 -0
  140. package/dist/src/index.d.ts +68 -0
  141. package/dist/src/index.js +78 -0
  142. package/dist/src/index.js.map +1 -0
  143. package/dist/src/index.test.d.ts +6 -0
  144. package/dist/src/index.test.js +12 -0
  145. package/dist/src/index.test.js.map +1 -0
  146. package/dist/src/mcp/google-auth-provider.d.ts +23 -0
  147. package/dist/src/mcp/google-auth-provider.js +63 -0
  148. package/dist/src/mcp/google-auth-provider.js.map +1 -0
  149. package/dist/src/mcp/google-auth-provider.test.d.ts +6 -0
  150. package/dist/src/mcp/google-auth-provider.test.js +54 -0
  151. package/dist/src/mcp/google-auth-provider.test.js.map +1 -0
  152. package/dist/src/mcp/oauth-provider.d.ts +147 -0
  153. package/dist/src/mcp/oauth-provider.js +484 -0
  154. package/dist/src/mcp/oauth-provider.js.map +1 -0
  155. package/dist/src/mcp/oauth-provider.test.d.ts +6 -0
  156. package/dist/src/mcp/oauth-provider.test.js +602 -0
  157. package/dist/src/mcp/oauth-provider.test.js.map +1 -0
  158. package/dist/src/mcp/oauth-token-storage.d.ts +83 -0
  159. package/dist/src/mcp/oauth-token-storage.js +151 -0
  160. package/dist/src/mcp/oauth-token-storage.js.map +1 -0
  161. package/dist/src/mcp/oauth-token-storage.test.d.ts +6 -0
  162. package/dist/src/mcp/oauth-token-storage.test.js +205 -0
  163. package/dist/src/mcp/oauth-token-storage.test.js.map +1 -0
  164. package/dist/src/mcp/oauth-utils.d.ts +109 -0
  165. package/dist/src/mcp/oauth-utils.js +183 -0
  166. package/dist/src/mcp/oauth-utils.js.map +1 -0
  167. package/dist/src/mcp/oauth-utils.test.d.ts +6 -0
  168. package/dist/src/mcp/oauth-utils.test.js +144 -0
  169. package/dist/src/mcp/oauth-utils.test.js.map +1 -0
  170. package/dist/src/prompts/mcp-prompts.d.ts +8 -0
  171. package/dist/src/prompts/mcp-prompts.js +13 -0
  172. package/dist/src/prompts/mcp-prompts.js.map +1 -0
  173. package/dist/src/prompts/prompt-registry.d.ts +34 -0
  174. package/dist/src/prompts/prompt-registry.js +63 -0
  175. package/dist/src/prompts/prompt-registry.js.map +1 -0
  176. package/dist/src/services/fileDiscoveryService.d.ts +35 -0
  177. package/dist/src/services/fileDiscoveryService.js +91 -0
  178. package/dist/src/services/fileDiscoveryService.js.map +1 -0
  179. package/dist/src/services/fileDiscoveryService.test.d.ts +6 -0
  180. package/dist/src/services/fileDiscoveryService.test.js +143 -0
  181. package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
  182. package/dist/src/services/gitService.d.ts +21 -0
  183. package/dist/src/services/gitService.js +101 -0
  184. package/dist/src/services/gitService.js.map +1 -0
  185. package/dist/src/services/gitService.test.d.ts +6 -0
  186. package/dist/src/services/gitService.test.js +209 -0
  187. package/dist/src/services/gitService.test.js.map +1 -0
  188. package/dist/src/services/loopDetectionService.d.ts +97 -0
  189. package/dist/src/services/loopDetectionService.js +340 -0
  190. package/dist/src/services/loopDetectionService.js.map +1 -0
  191. package/dist/src/services/loopDetectionService.test.d.ts +6 -0
  192. package/dist/src/services/loopDetectionService.test.js +484 -0
  193. package/dist/src/services/loopDetectionService.test.js.map +1 -0
  194. package/dist/src/services/shellExecutionService.d.ts +70 -0
  195. package/dist/src/services/shellExecutionService.js +175 -0
  196. package/dist/src/services/shellExecutionService.js.map +1 -0
  197. package/dist/src/services/shellExecutionService.test.d.ts +6 -0
  198. package/dist/src/services/shellExecutionService.test.js +272 -0
  199. package/dist/src/services/shellExecutionService.test.js.map +1 -0
  200. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +65 -0
  201. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +652 -0
  202. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
  203. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +6 -0
  204. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +186 -0
  205. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -0
  206. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +59 -0
  207. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +159 -0
  208. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
  209. package/dist/src/telemetry/constants.d.ts +23 -0
  210. package/dist/src/telemetry/constants.js +24 -0
  211. package/dist/src/telemetry/constants.js.map +1 -0
  212. package/dist/src/telemetry/file-exporters.d.ts +28 -0
  213. package/dist/src/telemetry/file-exporters.js +62 -0
  214. package/dist/src/telemetry/file-exporters.js.map +1 -0
  215. package/dist/src/telemetry/index.d.ts +18 -0
  216. package/dist/src/telemetry/index.js +20 -0
  217. package/dist/src/telemetry/index.js.map +1 -0
  218. package/dist/src/telemetry/integration.test.circular.d.ts +6 -0
  219. package/dist/src/telemetry/integration.test.circular.js +53 -0
  220. package/dist/src/telemetry/integration.test.circular.js.map +1 -0
  221. package/dist/src/telemetry/loggers.d.ts +18 -0
  222. package/dist/src/telemetry/loggers.js +268 -0
  223. package/dist/src/telemetry/loggers.js.map +1 -0
  224. package/dist/src/telemetry/loggers.test.circular.d.ts +6 -0
  225. package/dist/src/telemetry/loggers.test.circular.js +107 -0
  226. package/dist/src/telemetry/loggers.test.circular.js.map +1 -0
  227. package/dist/src/telemetry/loggers.test.d.ts +6 -0
  228. package/dist/src/telemetry/loggers.test.js +568 -0
  229. package/dist/src/telemetry/loggers.test.js.map +1 -0
  230. package/dist/src/telemetry/metrics.d.ts +20 -0
  231. package/dist/src/telemetry/metrics.js +150 -0
  232. package/dist/src/telemetry/metrics.js.map +1 -0
  233. package/dist/src/telemetry/metrics.test.d.ts +6 -0
  234. package/dist/src/telemetry/metrics.test.js +212 -0
  235. package/dist/src/telemetry/metrics.test.js.map +1 -0
  236. package/dist/src/telemetry/sdk.d.ts +9 -0
  237. package/dist/src/telemetry/sdk.js +127 -0
  238. package/dist/src/telemetry/sdk.js.map +1 -0
  239. package/dist/src/telemetry/telemetry.test.d.ts +6 -0
  240. package/dist/src/telemetry/telemetry.test.js +50 -0
  241. package/dist/src/telemetry/telemetry.test.js.map +1 -0
  242. package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
  243. package/dist/src/telemetry/tool-call-decision.js +29 -0
  244. package/dist/src/telemetry/tool-call-decision.js.map +1 -0
  245. package/dist/src/telemetry/types.d.ts +145 -0
  246. package/dist/src/telemetry/types.js +267 -0
  247. package/dist/src/telemetry/types.js.map +1 -0
  248. package/dist/src/telemetry/uiTelemetry.d.ts +71 -0
  249. package/dist/src/telemetry/uiTelemetry.js +140 -0
  250. package/dist/src/telemetry/uiTelemetry.js.map +1 -0
  251. package/dist/src/telemetry/uiTelemetry.test.d.ts +6 -0
  252. package/dist/src/telemetry/uiTelemetry.test.js +518 -0
  253. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
  254. package/dist/src/test-utils/mockWorkspaceContext.d.ts +13 -0
  255. package/dist/src/test-utils/mockWorkspaceContext.js +24 -0
  256. package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
  257. package/dist/src/test-utils/tools.d.ts +23 -0
  258. package/dist/src/test-utils/tools.js +41 -0
  259. package/dist/src/test-utils/tools.js.map +1 -0
  260. package/dist/src/tools/diffOptions.d.ts +9 -0
  261. package/dist/src/tools/diffOptions.js +38 -0
  262. package/dist/src/tools/diffOptions.js.map +1 -0
  263. package/dist/src/tools/diffOptions.test.d.ts +6 -0
  264. package/dist/src/tools/diffOptions.test.js +119 -0
  265. package/dist/src/tools/diffOptions.test.js.map +1 -0
  266. package/dist/src/tools/edit.d.ts +55 -0
  267. package/dist/src/tools/edit.js +398 -0
  268. package/dist/src/tools/edit.js.map +1 -0
  269. package/dist/src/tools/edit.test.d.ts +6 -0
  270. package/dist/src/tools/edit.test.js +681 -0
  271. package/dist/src/tools/edit.test.js.map +1 -0
  272. package/dist/src/tools/glob.d.ts +51 -0
  273. package/dist/src/tools/glob.js +226 -0
  274. package/dist/src/tools/glob.js.map +1 -0
  275. package/dist/src/tools/glob.test.d.ts +6 -0
  276. package/dist/src/tools/glob.test.js +330 -0
  277. package/dist/src/tools/glob.test.js.map +1 -0
  278. package/dist/src/tools/grep.d.ts +46 -0
  279. package/dist/src/tools/grep.js +503 -0
  280. package/dist/src/tools/grep.js.map +1 -0
  281. package/dist/src/tools/grep.test.d.ts +6 -0
  282. package/dist/src/tools/grep.test.js +272 -0
  283. package/dist/src/tools/grep.test.js.map +1 -0
  284. package/dist/src/tools/ls.d.ts +86 -0
  285. package/dist/src/tools/ls.js +224 -0
  286. package/dist/src/tools/ls.js.map +1 -0
  287. package/dist/src/tools/ls.test.d.ts +6 -0
  288. package/dist/src/tools/ls.test.js +356 -0
  289. package/dist/src/tools/ls.test.js.map +1 -0
  290. package/dist/src/tools/mcp-client.d.ts +149 -0
  291. package/dist/src/tools/mcp-client.js +844 -0
  292. package/dist/src/tools/mcp-client.js.map +1 -0
  293. package/dist/src/tools/mcp-client.test.d.ts +6 -0
  294. package/dist/src/tools/mcp-client.test.js +643 -0
  295. package/dist/src/tools/mcp-client.test.js.map +1 -0
  296. package/dist/src/tools/mcp-tool.d.ts +29 -0
  297. package/dist/src/tools/mcp-tool.js +202 -0
  298. package/dist/src/tools/mcp-tool.js.map +1 -0
  299. package/dist/src/tools/mcp-tool.test.d.ts +6 -0
  300. package/dist/src/tools/mcp-tool.test.js +501 -0
  301. package/dist/src/tools/mcp-tool.test.js.map +1 -0
  302. package/dist/src/tools/memoryTool.d.ts +43 -0
  303. package/dist/src/tools/memoryTool.js +290 -0
  304. package/dist/src/tools/memoryTool.js.map +1 -0
  305. package/dist/src/tools/memoryTool.test.d.ts +6 -0
  306. package/dist/src/tools/memoryTool.test.js +266 -0
  307. package/dist/src/tools/memoryTool.test.js.map +1 -0
  308. package/dist/src/tools/modifiable-tool.d.ts +32 -0
  309. package/dist/src/tools/modifiable-tool.js +88 -0
  310. package/dist/src/tools/modifiable-tool.js.map +1 -0
  311. package/dist/src/tools/modifiable-tool.test.d.ts +6 -0
  312. package/dist/src/tools/modifiable-tool.test.js +193 -0
  313. package/dist/src/tools/modifiable-tool.test.js.map +1 -0
  314. package/dist/src/tools/read-file.d.ts +34 -0
  315. package/dist/src/tools/read-file.js +152 -0
  316. package/dist/src/tools/read-file.js.map +1 -0
  317. package/dist/src/tools/read-file.test.d.ts +6 -0
  318. package/dist/src/tools/read-file.test.js +300 -0
  319. package/dist/src/tools/read-file.test.js.map +1 -0
  320. package/dist/src/tools/read-many-files.d.ts +61 -0
  321. package/dist/src/tools/read-many-files.js +421 -0
  322. package/dist/src/tools/read-many-files.js.map +1 -0
  323. package/dist/src/tools/read-many-files.test.d.ts +6 -0
  324. package/dist/src/tools/read-many-files.test.js +455 -0
  325. package/dist/src/tools/read-many-files.test.js.map +1 -0
  326. package/dist/src/tools/shell.d.ts +23 -0
  327. package/dist/src/tools/shell.js +313 -0
  328. package/dist/src/tools/shell.js.map +1 -0
  329. package/dist/src/tools/shell.test.d.ts +6 -0
  330. package/dist/src/tools/shell.test.js +321 -0
  331. package/dist/src/tools/shell.test.js.map +1 -0
  332. package/dist/src/tools/tool-error.d.ts +26 -0
  333. package/dist/src/tools/tool-error.js +31 -0
  334. package/dist/src/tools/tool-error.js.map +1 -0
  335. package/dist/src/tools/tool-registry.d.ts +85 -0
  336. package/dist/src/tools/tool-registry.js +390 -0
  337. package/dist/src/tools/tool-registry.js.map +1 -0
  338. package/dist/src/tools/tool-registry.test.d.ts +6 -0
  339. package/dist/src/tools/tool-registry.test.js +417 -0
  340. package/dist/src/tools/tool-registry.test.js.map +1 -0
  341. package/dist/src/tools/tools.d.ts +328 -0
  342. package/dist/src/tools/tools.js +281 -0
  343. package/dist/src/tools/tools.js.map +1 -0
  344. package/dist/src/tools/tools.test.d.ts +6 -0
  345. package/dist/src/tools/tools.test.js +117 -0
  346. package/dist/src/tools/tools.test.js.map +1 -0
  347. package/dist/src/tools/web-fetch.d.ts +29 -0
  348. package/dist/src/tools/web-fetch.js +246 -0
  349. package/dist/src/tools/web-fetch.js.map +1 -0
  350. package/dist/src/tools/web-fetch.test.d.ts +6 -0
  351. package/dist/src/tools/web-fetch.test.js +71 -0
  352. package/dist/src/tools/web-fetch.test.js.map +1 -0
  353. package/dist/src/tools/web-search.d.ts +49 -0
  354. package/dist/src/tools/web-search.js +120 -0
  355. package/dist/src/tools/web-search.js.map +1 -0
  356. package/dist/src/tools/write-file.d.ts +46 -0
  357. package/dist/src/tools/write-file.js +321 -0
  358. package/dist/src/tools/write-file.js.map +1 -0
  359. package/dist/src/tools/write-file.test.d.ts +6 -0
  360. package/dist/src/tools/write-file.test.js +572 -0
  361. package/dist/src/tools/write-file.test.js.map +1 -0
  362. package/dist/src/utils/LruCache.d.ts +13 -0
  363. package/dist/src/utils/LruCache.js +38 -0
  364. package/dist/src/utils/LruCache.js.map +1 -0
  365. package/dist/src/utils/bfsFileSearch.d.ts +24 -0
  366. package/dist/src/utils/bfsFileSearch.js +89 -0
  367. package/dist/src/utils/bfsFileSearch.js.map +1 -0
  368. package/dist/src/utils/bfsFileSearch.test.d.ts +6 -0
  369. package/dist/src/utils/bfsFileSearch.test.js +163 -0
  370. package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
  371. package/dist/src/utils/browser.d.ts +13 -0
  372. package/dist/src/utils/browser.js +49 -0
  373. package/dist/src/utils/browser.js.map +1 -0
  374. package/dist/src/utils/editCorrector.d.ts +53 -0
  375. package/dist/src/utils/editCorrector.js +546 -0
  376. package/dist/src/utils/editCorrector.js.map +1 -0
  377. package/dist/src/utils/editCorrector.test.d.ts +6 -0
  378. package/dist/src/utils/editCorrector.test.js +564 -0
  379. package/dist/src/utils/editCorrector.test.js.map +1 -0
  380. package/dist/src/utils/editor.d.ts +28 -0
  381. package/dist/src/utils/editor.js +186 -0
  382. package/dist/src/utils/editor.js.map +1 -0
  383. package/dist/src/utils/editor.test.d.ts +6 -0
  384. package/dist/src/utils/editor.test.js +445 -0
  385. package/dist/src/utils/editor.test.js.map +1 -0
  386. package/dist/src/utils/environmentContext.d.ts +21 -0
  387. package/dist/src/utils/environmentContext.js +90 -0
  388. package/dist/src/utils/environmentContext.js.map +1 -0
  389. package/dist/src/utils/environmentContext.test.d.ts +6 -0
  390. package/dist/src/utils/environmentContext.test.js +139 -0
  391. package/dist/src/utils/environmentContext.test.js.map +1 -0
  392. package/dist/src/utils/errorReporting.d.ts +14 -0
  393. package/dist/src/utils/errorReporting.js +88 -0
  394. package/dist/src/utils/errorReporting.js.map +1 -0
  395. package/dist/src/utils/errorReporting.test.d.ts +6 -0
  396. package/dist/src/utils/errorReporting.test.js +130 -0
  397. package/dist/src/utils/errorReporting.test.js.map +1 -0
  398. package/dist/src/utils/errors.d.ts +14 -0
  399. package/dist/src/utils/errors.js +54 -0
  400. package/dist/src/utils/errors.js.map +1 -0
  401. package/dist/src/utils/fetch.d.ts +11 -0
  402. package/dist/src/utils/fetch.js +51 -0
  403. package/dist/src/utils/fetch.js.map +1 -0
  404. package/dist/src/utils/fileUtils.d.ts +56 -0
  405. package/dist/src/utils/fileUtils.js +314 -0
  406. package/dist/src/utils/fileUtils.js.map +1 -0
  407. package/dist/src/utils/fileUtils.test.d.ts +6 -0
  408. package/dist/src/utils/fileUtils.test.js +363 -0
  409. package/dist/src/utils/fileUtils.test.js.map +1 -0
  410. package/dist/src/utils/filesearch/crawlCache.d.ts +25 -0
  411. package/dist/src/utils/filesearch/crawlCache.js +57 -0
  412. package/dist/src/utils/filesearch/crawlCache.js.map +1 -0
  413. package/dist/src/utils/filesearch/crawlCache.test.d.ts +6 -0
  414. package/dist/src/utils/filesearch/crawlCache.test.js +103 -0
  415. package/dist/src/utils/filesearch/crawlCache.test.js.map +1 -0
  416. package/dist/src/utils/filesearch/fileSearch.d.ts +81 -0
  417. package/dist/src/utils/filesearch/fileSearch.js +241 -0
  418. package/dist/src/utils/filesearch/fileSearch.js.map +1 -0
  419. package/dist/src/utils/filesearch/fileSearch.test.d.ts +6 -0
  420. package/dist/src/utils/filesearch/fileSearch.test.js +654 -0
  421. package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -0
  422. package/dist/src/utils/filesearch/ignore.d.ts +35 -0
  423. package/dist/src/utils/filesearch/ignore.js +81 -0
  424. package/dist/src/utils/filesearch/ignore.js.map +1 -0
  425. package/dist/src/utils/filesearch/ignore.test.d.ts +6 -0
  426. package/dist/src/utils/filesearch/ignore.test.js +57 -0
  427. package/dist/src/utils/filesearch/ignore.test.js.map +1 -0
  428. package/dist/src/utils/filesearch/result-cache.d.ts +34 -0
  429. package/dist/src/utils/filesearch/result-cache.js +61 -0
  430. package/dist/src/utils/filesearch/result-cache.js.map +1 -0
  431. package/dist/src/utils/filesearch/result-cache.test.d.ts +6 -0
  432. package/dist/src/utils/filesearch/result-cache.test.js +47 -0
  433. package/dist/src/utils/filesearch/result-cache.test.js.map +1 -0
  434. package/dist/src/utils/flashFallback.integration.test.d.ts +6 -0
  435. package/dist/src/utils/flashFallback.integration.test.js +118 -0
  436. package/dist/src/utils/flashFallback.integration.test.js.map +1 -0
  437. package/dist/src/utils/formatters.d.ts +6 -0
  438. package/dist/src/utils/formatters.js +16 -0
  439. package/dist/src/utils/formatters.js.map +1 -0
  440. package/dist/src/utils/generateContentResponseUtilities.d.ts +14 -0
  441. package/dist/src/utils/generateContentResponseUtilities.js +92 -0
  442. package/dist/src/utils/generateContentResponseUtilities.js.map +1 -0
  443. package/dist/src/utils/generateContentResponseUtilities.test.d.ts +6 -0
  444. package/dist/src/utils/generateContentResponseUtilities.test.js +273 -0
  445. package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
  446. package/dist/src/utils/getFolderStructure.d.ts +31 -0
  447. package/dist/src/utils/getFolderStructure.js +246 -0
  448. package/dist/src/utils/getFolderStructure.js.map +1 -0
  449. package/dist/src/utils/getFolderStructure.test.d.ts +6 -0
  450. package/dist/src/utils/getFolderStructure.test.js +282 -0
  451. package/dist/src/utils/getFolderStructure.test.js.map +1 -0
  452. package/dist/src/utils/gitIgnoreParser.d.ts +20 -0
  453. package/dist/src/utils/gitIgnoreParser.js +61 -0
  454. package/dist/src/utils/gitIgnoreParser.js.map +1 -0
  455. package/dist/src/utils/gitIgnoreParser.test.d.ts +6 -0
  456. package/dist/src/utils/gitIgnoreParser.test.js +154 -0
  457. package/dist/src/utils/gitIgnoreParser.test.js.map +1 -0
  458. package/dist/src/utils/gitUtils.d.ts +17 -0
  459. package/dist/src/utils/gitUtils.js +61 -0
  460. package/dist/src/utils/gitUtils.js.map +1 -0
  461. package/dist/src/utils/memoryDiscovery.d.ts +15 -0
  462. package/dist/src/utils/memoryDiscovery.js +219 -0
  463. package/dist/src/utils/memoryDiscovery.js.map +1 -0
  464. package/dist/src/utils/memoryDiscovery.test.d.ts +6 -0
  465. package/dist/src/utils/memoryDiscovery.test.js +181 -0
  466. package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
  467. package/dist/src/utils/memoryImportProcessor.d.ts +42 -0
  468. package/dist/src/utils/memoryImportProcessor.js +300 -0
  469. package/dist/src/utils/memoryImportProcessor.js.map +1 -0
  470. package/dist/src/utils/memoryImportProcessor.test.d.ts +6 -0
  471. package/dist/src/utils/memoryImportProcessor.test.js +715 -0
  472. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -0
  473. package/dist/src/utils/messageInspectors.d.ts +8 -0
  474. package/dist/src/utils/messageInspectors.js +16 -0
  475. package/dist/src/utils/messageInspectors.js.map +1 -0
  476. package/dist/src/utils/nextSpeakerChecker.d.ts +12 -0
  477. package/dist/src/utils/nextSpeakerChecker.js +92 -0
  478. package/dist/src/utils/nextSpeakerChecker.js.map +1 -0
  479. package/dist/src/utils/nextSpeakerChecker.test.d.ts +6 -0
  480. package/dist/src/utils/nextSpeakerChecker.test.js +168 -0
  481. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
  482. package/dist/src/utils/partUtils.d.ts +14 -0
  483. package/dist/src/utils/partUtils.js +65 -0
  484. package/dist/src/utils/partUtils.js.map +1 -0
  485. package/dist/src/utils/partUtils.test.d.ts +6 -0
  486. package/dist/src/utils/partUtils.test.js +130 -0
  487. package/dist/src/utils/partUtils.test.js.map +1 -0
  488. package/dist/src/utils/paths.d.ts +68 -0
  489. package/dist/src/utils/paths.js +170 -0
  490. package/dist/src/utils/paths.js.map +1 -0
  491. package/dist/src/utils/paths.test.d.ts +6 -0
  492. package/dist/src/utils/paths.test.js +153 -0
  493. package/dist/src/utils/paths.test.js.map +1 -0
  494. package/dist/src/utils/quotaErrorDetection.d.ts +22 -0
  495. package/dist/src/utils/quotaErrorDetection.js +65 -0
  496. package/dist/src/utils/quotaErrorDetection.js.map +1 -0
  497. package/dist/src/utils/retry.d.ts +30 -0
  498. package/dist/src/utils/retry.js +276 -0
  499. package/dist/src/utils/retry.js.map +1 -0
  500. package/dist/src/utils/retry.test.d.ts +6 -0
  501. package/dist/src/utils/retry.test.js +322 -0
  502. package/dist/src/utils/retry.test.js.map +1 -0
  503. package/dist/src/utils/safeJsonStringify.d.ts +13 -0
  504. package/dist/src/utils/safeJsonStringify.js +25 -0
  505. package/dist/src/utils/safeJsonStringify.js.map +1 -0
  506. package/dist/src/utils/safeJsonStringify.test.d.ts +6 -0
  507. package/dist/src/utils/safeJsonStringify.test.js +61 -0
  508. package/dist/src/utils/safeJsonStringify.test.js.map +1 -0
  509. package/dist/src/utils/schemaValidator.d.ts +22 -0
  510. package/dist/src/utils/schemaValidator.js +65 -0
  511. package/dist/src/utils/schemaValidator.js.map +1 -0
  512. package/dist/src/utils/secure-browser-launcher.d.ts +23 -0
  513. package/dist/src/utils/secure-browser-launcher.js +164 -0
  514. package/dist/src/utils/secure-browser-launcher.js.map +1 -0
  515. package/dist/src/utils/secure-browser-launcher.test.d.ts +6 -0
  516. package/dist/src/utils/secure-browser-launcher.test.js +149 -0
  517. package/dist/src/utils/secure-browser-launcher.test.js.map +1 -0
  518. package/dist/src/utils/session.d.ts +6 -0
  519. package/dist/src/utils/session.js +8 -0
  520. package/dist/src/utils/session.js.map +1 -0
  521. package/dist/src/utils/shell-utils.d.ts +78 -0
  522. package/dist/src/utils/shell-utils.js +306 -0
  523. package/dist/src/utils/shell-utils.js.map +1 -0
  524. package/dist/src/utils/shell-utils.test.d.ts +6 -0
  525. package/dist/src/utils/shell-utils.test.js +200 -0
  526. package/dist/src/utils/shell-utils.test.js.map +1 -0
  527. package/dist/src/utils/summarizer.d.ts +25 -0
  528. package/dist/src/utils/summarizer.js +51 -0
  529. package/dist/src/utils/summarizer.js.map +1 -0
  530. package/dist/src/utils/summarizer.test.d.ts +6 -0
  531. package/dist/src/utils/summarizer.test.js +131 -0
  532. package/dist/src/utils/summarizer.test.js.map +1 -0
  533. package/dist/src/utils/systemEncoding.d.ts +40 -0
  534. package/dist/src/utils/systemEncoding.js +149 -0
  535. package/dist/src/utils/systemEncoding.js.map +1 -0
  536. package/dist/src/utils/systemEncoding.test.d.ts +6 -0
  537. package/dist/src/utils/systemEncoding.test.js +368 -0
  538. package/dist/src/utils/systemEncoding.test.js.map +1 -0
  539. package/dist/src/utils/testUtils.d.ts +29 -0
  540. package/dist/src/utils/testUtils.js +70 -0
  541. package/dist/src/utils/testUtils.js.map +1 -0
  542. package/dist/src/utils/textUtils.d.ts +13 -0
  543. package/dist/src/utils/textUtils.js +28 -0
  544. package/dist/src/utils/textUtils.js.map +1 -0
  545. package/dist/src/utils/user_account.d.ts +9 -0
  546. package/dist/src/utils/user_account.js +99 -0
  547. package/dist/src/utils/user_account.js.map +1 -0
  548. package/dist/src/utils/user_account.test.d.ts +6 -0
  549. package/dist/src/utils/user_account.test.js +153 -0
  550. package/dist/src/utils/user_account.test.js.map +1 -0
  551. package/dist/src/utils/user_id.d.ts +11 -0
  552. package/dist/src/utils/user_id.js +49 -0
  553. package/dist/src/utils/user_id.js.map +1 -0
  554. package/dist/src/utils/user_id.test.d.ts +6 -0
  555. package/dist/src/utils/user_id.test.js +21 -0
  556. package/dist/src/utils/user_id.test.js.map +1 -0
  557. package/dist/src/utils/workspaceContext.d.ts +51 -0
  558. package/dist/src/utils/workspaceContext.js +139 -0
  559. package/dist/src/utils/workspaceContext.js.map +1 -0
  560. package/dist/src/utils/workspaceContext.test.d.ts +6 -0
  561. package/dist/src/utils/workspaceContext.test.js +209 -0
  562. package/dist/src/utils/workspaceContext.test.js.map +1 -0
  563. package/dist/tsconfig.tsbuildinfo +1 -0
  564. package/package.json +76 -0
@@ -0,0 +1,300 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
7
+ import { ReadFileTool } from './read-file.js';
8
+ import { ToolErrorType } from './tool-error.js';
9
+ import path from 'path';
10
+ import os from 'os';
11
+ import fs from 'fs';
12
+ import fsp from 'fs/promises';
13
+ import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
14
+ import { createMockWorkspaceContext } from '../test-utils/mockWorkspaceContext.js';
15
+ describe('ReadFileTool', () => {
16
+ let tempRootDir;
17
+ let tool;
18
+ const abortSignal = new AbortController().signal;
19
+ beforeEach(async () => {
20
+ // Create a unique temporary root directory for each test run
21
+ tempRootDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'read-file-tool-root-'));
22
+ const mockConfigInstance = {
23
+ getFileService: () => new FileDiscoveryService(tempRootDir),
24
+ getTargetDir: () => tempRootDir,
25
+ getWorkspaceContext: () => createMockWorkspaceContext(tempRootDir),
26
+ };
27
+ tool = new ReadFileTool(mockConfigInstance);
28
+ });
29
+ afterEach(async () => {
30
+ // Clean up the temporary root directory
31
+ if (fs.existsSync(tempRootDir)) {
32
+ await fsp.rm(tempRootDir, { recursive: true, force: true });
33
+ }
34
+ });
35
+ describe('build', () => {
36
+ it('should return an invocation for valid params (absolute path within root)', () => {
37
+ const params = {
38
+ absolute_path: path.join(tempRootDir, 'test.txt'),
39
+ };
40
+ const result = tool.build(params);
41
+ expect(typeof result).not.toBe('string');
42
+ });
43
+ it('should throw error if file path is relative', () => {
44
+ const params = {
45
+ absolute_path: 'relative/path.txt',
46
+ };
47
+ expect(() => tool.build(params)).toThrow('File path must be absolute, but was relative: relative/path.txt. You must provide an absolute path.');
48
+ });
49
+ it('should throw error if path is outside root', () => {
50
+ const params = {
51
+ absolute_path: '/outside/root.txt',
52
+ };
53
+ expect(() => tool.build(params)).toThrow(/File path must be within one of the workspace directories/);
54
+ });
55
+ it('should throw error if offset is negative', () => {
56
+ const params = {
57
+ absolute_path: path.join(tempRootDir, 'test.txt'),
58
+ offset: -1,
59
+ };
60
+ expect(() => tool.build(params)).toThrow('Offset must be a non-negative number');
61
+ });
62
+ it('should throw error if limit is zero or negative', () => {
63
+ const params = {
64
+ absolute_path: path.join(tempRootDir, 'test.txt'),
65
+ limit: 0,
66
+ };
67
+ expect(() => tool.build(params)).toThrow('Limit must be a positive number');
68
+ });
69
+ });
70
+ describe('getDescription', () => {
71
+ it('should return relative path without limit/offset', () => {
72
+ const subDir = path.join(tempRootDir, 'sub', 'dir');
73
+ const params = {
74
+ absolute_path: path.join(subDir, 'file.txt'),
75
+ };
76
+ const invocation = tool.build(params);
77
+ expect(typeof invocation).not.toBe('string');
78
+ expect(invocation.getDescription()).toBe(path.join('sub', 'dir', 'file.txt'));
79
+ });
80
+ it('should return shortened path when file path is deep', () => {
81
+ const deepPath = path.join(tempRootDir, 'very', 'deep', 'directory', 'structure', 'that', 'exceeds', 'the', 'normal', 'limit', 'file.txt');
82
+ const params = { absolute_path: deepPath };
83
+ const invocation = tool.build(params);
84
+ expect(typeof invocation).not.toBe('string');
85
+ const desc = invocation.getDescription();
86
+ expect(desc).toContain('...');
87
+ expect(desc).toContain('file.txt');
88
+ });
89
+ it('should handle non-normalized file paths correctly', () => {
90
+ const subDir = path.join(tempRootDir, 'sub', 'dir');
91
+ const params = {
92
+ absolute_path: path.join(subDir, '..', 'dir', 'file.txt'),
93
+ };
94
+ const invocation = tool.build(params);
95
+ expect(typeof invocation).not.toBe('string');
96
+ expect(invocation.getDescription()).toBe(path.join('sub', 'dir', 'file.txt'));
97
+ });
98
+ it('should return . if path is the root directory', () => {
99
+ const params = { absolute_path: tempRootDir };
100
+ const invocation = tool.build(params);
101
+ expect(typeof invocation).not.toBe('string');
102
+ expect(invocation.getDescription()).toBe('.');
103
+ });
104
+ });
105
+ describe('execute', () => {
106
+ it('should return error if file does not exist', async () => {
107
+ const filePath = path.join(tempRootDir, 'nonexistent.txt');
108
+ const params = { absolute_path: filePath };
109
+ const invocation = tool.build(params);
110
+ const result = await invocation.execute(abortSignal);
111
+ expect(result).toEqual({
112
+ llmContent: 'Could not read file because no file was found at the specified path.',
113
+ returnDisplay: 'File not found.',
114
+ error: {
115
+ message: `File not found: ${filePath}`,
116
+ type: ToolErrorType.FILE_NOT_FOUND,
117
+ },
118
+ });
119
+ });
120
+ it('should return success result for a text file', async () => {
121
+ const filePath = path.join(tempRootDir, 'textfile.txt');
122
+ const fileContent = 'This is a test file.';
123
+ await fsp.writeFile(filePath, fileContent, 'utf-8');
124
+ const params = { absolute_path: filePath };
125
+ const invocation = tool.build(params);
126
+ expect(await invocation.execute(abortSignal)).toEqual({
127
+ llmContent: fileContent,
128
+ returnDisplay: '',
129
+ });
130
+ });
131
+ it('should return error if path is a directory', async () => {
132
+ const dirPath = path.join(tempRootDir, 'directory');
133
+ await fsp.mkdir(dirPath);
134
+ const params = { absolute_path: dirPath };
135
+ const invocation = tool.build(params);
136
+ const result = await invocation.execute(abortSignal);
137
+ expect(result).toEqual({
138
+ llmContent: 'Could not read file because the provided path is a directory, not a file.',
139
+ returnDisplay: 'Path is a directory.',
140
+ error: {
141
+ message: `Path is a directory, not a file: ${dirPath}`,
142
+ type: ToolErrorType.INVALID_TOOL_PARAMS,
143
+ },
144
+ });
145
+ });
146
+ it('should return error for a file that is too large', async () => {
147
+ const filePath = path.join(tempRootDir, 'largefile.txt');
148
+ // 21MB of content exceeds 20MB limit
149
+ const largeContent = 'x'.repeat(21 * 1024 * 1024);
150
+ await fsp.writeFile(filePath, largeContent, 'utf-8');
151
+ const params = { absolute_path: filePath };
152
+ const invocation = tool.build(params);
153
+ const result = await invocation.execute(abortSignal);
154
+ expect(result).toHaveProperty('error');
155
+ expect(result.error?.type).toBe(ToolErrorType.FILE_TOO_LARGE);
156
+ expect(result.error?.message).toContain('File size exceeds the 20MB limit');
157
+ });
158
+ it('should handle text file with lines exceeding maximum length', async () => {
159
+ const filePath = path.join(tempRootDir, 'longlines.txt');
160
+ const longLine = 'a'.repeat(2500); // Exceeds MAX_LINE_LENGTH_TEXT_FILE (2000)
161
+ const fileContent = `Short line\n${longLine}\nAnother short line`;
162
+ await fsp.writeFile(filePath, fileContent, 'utf-8');
163
+ const params = { absolute_path: filePath };
164
+ const invocation = tool.build(params);
165
+ const result = await invocation.execute(abortSignal);
166
+ expect(result.llmContent).toContain('IMPORTANT: The file content has been truncated');
167
+ expect(result.llmContent).toContain('--- FILE CONTENT (truncated) ---');
168
+ expect(result.returnDisplay).toContain('some lines were shortened');
169
+ });
170
+ it('should handle image file and return appropriate content', async () => {
171
+ const imagePath = path.join(tempRootDir, 'image.png');
172
+ // Minimal PNG header
173
+ const pngHeader = Buffer.from([
174
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
175
+ ]);
176
+ await fsp.writeFile(imagePath, pngHeader);
177
+ const params = { absolute_path: imagePath };
178
+ const invocation = tool.build(params);
179
+ const result = await invocation.execute(abortSignal);
180
+ expect(result.llmContent).toEqual({
181
+ inlineData: {
182
+ data: pngHeader.toString('base64'),
183
+ mimeType: 'image/png',
184
+ },
185
+ });
186
+ expect(result.returnDisplay).toBe('Read image file: image.png');
187
+ });
188
+ it('should handle PDF file and return appropriate content', async () => {
189
+ const pdfPath = path.join(tempRootDir, 'document.pdf');
190
+ // Minimal PDF header
191
+ const pdfHeader = Buffer.from('%PDF-1.4');
192
+ await fsp.writeFile(pdfPath, pdfHeader);
193
+ const params = { absolute_path: pdfPath };
194
+ const invocation = tool.build(params);
195
+ const result = await invocation.execute(abortSignal);
196
+ expect(result.llmContent).toEqual({
197
+ inlineData: {
198
+ data: pdfHeader.toString('base64'),
199
+ mimeType: 'application/pdf',
200
+ },
201
+ });
202
+ expect(result.returnDisplay).toBe('Read pdf file: document.pdf');
203
+ });
204
+ it('should handle binary file and skip content', async () => {
205
+ const binPath = path.join(tempRootDir, 'binary.bin');
206
+ // Binary data with null bytes
207
+ const binaryData = Buffer.from([0x00, 0xff, 0x00, 0xff]);
208
+ await fsp.writeFile(binPath, binaryData);
209
+ const params = { absolute_path: binPath };
210
+ const invocation = tool.build(params);
211
+ const result = await invocation.execute(abortSignal);
212
+ expect(result.llmContent).toBe('Cannot display content of binary file: binary.bin');
213
+ expect(result.returnDisplay).toBe('Skipped binary file: binary.bin');
214
+ });
215
+ it('should handle SVG file as text', async () => {
216
+ const svgPath = path.join(tempRootDir, 'image.svg');
217
+ const svgContent = '<svg><circle cx="50" cy="50" r="40"/></svg>';
218
+ await fsp.writeFile(svgPath, svgContent, 'utf-8');
219
+ const params = { absolute_path: svgPath };
220
+ const invocation = tool.build(params);
221
+ const result = await invocation.execute(abortSignal);
222
+ expect(result.llmContent).toBe(svgContent);
223
+ expect(result.returnDisplay).toBe('Read SVG as text: image.svg');
224
+ });
225
+ it('should handle large SVG file', async () => {
226
+ const svgPath = path.join(tempRootDir, 'large.svg');
227
+ // Create SVG content larger than 1MB
228
+ const largeContent = '<svg>' + 'x'.repeat(1024 * 1024 + 1) + '</svg>';
229
+ await fsp.writeFile(svgPath, largeContent, 'utf-8');
230
+ const params = { absolute_path: svgPath };
231
+ const invocation = tool.build(params);
232
+ const result = await invocation.execute(abortSignal);
233
+ expect(result.llmContent).toBe('Cannot display content of SVG file larger than 1MB: large.svg');
234
+ expect(result.returnDisplay).toBe('Skipped large SVG file (>1MB): large.svg');
235
+ });
236
+ it('should handle empty file', async () => {
237
+ const emptyPath = path.join(tempRootDir, 'empty.txt');
238
+ await fsp.writeFile(emptyPath, '', 'utf-8');
239
+ const params = { absolute_path: emptyPath };
240
+ const invocation = tool.build(params);
241
+ const result = await invocation.execute(abortSignal);
242
+ expect(result.llmContent).toBe('');
243
+ expect(result.returnDisplay).toBe('');
244
+ });
245
+ it('should support offset and limit for text files', async () => {
246
+ const filePath = path.join(tempRootDir, 'paginated.txt');
247
+ const lines = Array.from({ length: 20 }, (_, i) => `Line ${i + 1}`);
248
+ const fileContent = lines.join('\n');
249
+ await fsp.writeFile(filePath, fileContent, 'utf-8');
250
+ const params = {
251
+ absolute_path: filePath,
252
+ offset: 5, // Start from line 6
253
+ limit: 3,
254
+ };
255
+ const invocation = tool.build(params);
256
+ const result = await invocation.execute(abortSignal);
257
+ expect(result.llmContent).toContain('IMPORTANT: The file content has been truncated');
258
+ expect(result.llmContent).toContain('Status: Showing lines 6-8 of 20 total lines');
259
+ expect(result.llmContent).toContain('Line 6');
260
+ expect(result.llmContent).toContain('Line 7');
261
+ expect(result.llmContent).toContain('Line 8');
262
+ expect(result.returnDisplay).toBe('Read lines 6-8 of 20 from paginated.txt');
263
+ });
264
+ describe('with .geminiignore', () => {
265
+ beforeEach(async () => {
266
+ await fsp.writeFile(path.join(tempRootDir, '.geminiignore'), ['foo.*', 'ignored/'].join('\n'));
267
+ });
268
+ it('should throw error if path is ignored by a .geminiignore pattern', async () => {
269
+ const ignoredFilePath = path.join(tempRootDir, 'foo.bar');
270
+ await fsp.writeFile(ignoredFilePath, 'content', 'utf-8');
271
+ const params = {
272
+ absolute_path: ignoredFilePath,
273
+ };
274
+ const expectedError = `File path '${ignoredFilePath}' is ignored by .geminiignore pattern(s).`;
275
+ expect(() => tool.build(params)).toThrow(expectedError);
276
+ });
277
+ it('should throw error if file is in an ignored directory', async () => {
278
+ const ignoredDirPath = path.join(tempRootDir, 'ignored');
279
+ await fsp.mkdir(ignoredDirPath, { recursive: true });
280
+ const ignoredFilePath = path.join(ignoredDirPath, 'file.txt');
281
+ await fsp.writeFile(ignoredFilePath, 'content', 'utf-8');
282
+ const params = {
283
+ absolute_path: ignoredFilePath,
284
+ };
285
+ const expectedError = `File path '${ignoredFilePath}' is ignored by .geminiignore pattern(s).`;
286
+ expect(() => tool.build(params)).toThrow(expectedError);
287
+ });
288
+ it('should allow reading non-ignored files', async () => {
289
+ const allowedFilePath = path.join(tempRootDir, 'allowed.txt');
290
+ await fsp.writeFile(allowedFilePath, 'content', 'utf-8');
291
+ const params = {
292
+ absolute_path: allowedFilePath,
293
+ };
294
+ const invocation = tool.build(params);
295
+ expect(typeof invocation).not.toBe('string');
296
+ });
297
+ });
298
+ });
299
+ });
300
+ //# sourceMappingURL=read-file.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file.test.js","sourceRoot":"","sources":["../../../src/tools/read-file.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,GAAG,MAAM,aAAa,CAAC;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAGnF,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,WAAmB,CAAC;IACxB,IAAI,IAAkB,CAAC;IACvB,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC,MAAM,CAAC;IAEjD,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,6DAA6D;QAC7D,WAAW,GAAG,MAAM,GAAG,CAAC,OAAO,CAC7B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,sBAAsB,CAAC,CAC/C,CAAC;QAEF,MAAM,kBAAkB,GAAG;YACzB,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,oBAAoB,CAAC,WAAW,CAAC;YAC3D,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW;YAC/B,mBAAmB,EAAE,GAAG,EAAE,CAAC,0BAA0B,CAAC,WAAW,CAAC;SAC9C,CAAC;QACvB,IAAI,GAAG,IAAI,YAAY,CAAC,kBAAkB,CA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,QAAQ,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BaseTool, ToolResult } from './tools.js';
7
+ import { Config } from '../config/config.js';
8
+ /**
9
+ * Parameters for the ReadManyFilesTool.
10
+ */
11
+ export interface ReadManyFilesParams {
12
+ /**
13
+ * An array of file paths or directory paths to search within.
14
+ * Paths are relative to the tool's configured target directory.
15
+ * Glob patterns can be used directly in these paths.
16
+ */
17
+ paths: string[];
18
+ /**
19
+ * Optional. Glob patterns for files to include.
20
+ * These are effectively combined with the `paths`.
21
+ * Example: ["*.ts", "src/** /*.md"]
22
+ */
23
+ include?: string[];
24
+ /**
25
+ * Optional. Glob patterns for files/directories to exclude.
26
+ * Applied as ignore patterns.
27
+ * Example: ["*.log", "dist/**"]
28
+ */
29
+ exclude?: string[];
30
+ /**
31
+ * Optional. Search directories recursively.
32
+ * This is generally controlled by glob patterns (e.g., `**`).
33
+ * The glob implementation is recursive by default for `**`.
34
+ * For simplicity, we'll rely on `**` for recursion.
35
+ */
36
+ recursive?: boolean;
37
+ /**
38
+ * Optional. Apply default exclusion patterns. Defaults to true.
39
+ */
40
+ useDefaultExcludes?: boolean;
41
+ /**
42
+ * Whether to respect .gitignore and .geminiignore patterns (optional, defaults to true)
43
+ */
44
+ file_filtering_options?: {
45
+ respect_git_ignore?: boolean;
46
+ respect_gemini_ignore?: boolean;
47
+ };
48
+ }
49
+ /**
50
+ * Tool implementation for finding and reading multiple text files from the local filesystem
51
+ * within a specified target directory. The content is concatenated.
52
+ * It is intended to run in an environment with access to the local file system (e.g., a Node.js backend).
53
+ */
54
+ export declare class ReadManyFilesTool extends BaseTool<ReadManyFilesParams, ToolResult> {
55
+ private config;
56
+ static readonly Name: string;
57
+ constructor(config: Config);
58
+ validateParams(params: ReadManyFilesParams): string | null;
59
+ getDescription(params: ReadManyFilesParams): string;
60
+ execute(params: ReadManyFilesParams, signal: AbortSignal): Promise<ToolResult>;
61
+ }