@office-ai/aioncli-core 0.2.3 → 0.18.4

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 (1051) hide show
  1. package/dist/index.d.ts +16 -3
  2. package/dist/index.js +15 -3
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/agents/codebase-investigator.d.ts +46 -0
  5. package/dist/src/agents/codebase-investigator.js +132 -0
  6. package/dist/src/agents/codebase-investigator.js.map +1 -0
  7. package/dist/src/agents/codebase-investigator.test.js +35 -0
  8. package/dist/src/agents/codebase-investigator.test.js.map +1 -0
  9. package/dist/src/agents/executor.d.ts +114 -0
  10. package/dist/src/agents/executor.js +779 -0
  11. package/dist/src/agents/executor.js.map +1 -0
  12. package/dist/src/agents/executor.test.js +1362 -0
  13. package/dist/src/agents/executor.test.js.map +1 -0
  14. package/dist/src/agents/invocation.d.ts +46 -0
  15. package/dist/src/agents/invocation.js +102 -0
  16. package/dist/src/agents/invocation.js.map +1 -0
  17. package/dist/src/agents/invocation.test.js +215 -0
  18. package/dist/src/agents/invocation.test.js.map +1 -0
  19. package/dist/src/agents/registry.d.ts +40 -0
  20. package/dist/src/agents/registry.js +105 -0
  21. package/dist/src/agents/registry.js.map +1 -0
  22. package/dist/src/agents/registry.test.d.ts +6 -0
  23. package/dist/src/agents/registry.test.js +160 -0
  24. package/dist/src/agents/registry.test.js.map +1 -0
  25. package/dist/src/agents/schema-utils.d.ts +39 -0
  26. package/dist/src/agents/schema-utils.js +57 -0
  27. package/dist/src/agents/schema-utils.js.map +1 -0
  28. package/dist/src/agents/schema-utils.test.d.ts +6 -0
  29. package/dist/src/agents/schema-utils.test.js +144 -0
  30. package/dist/src/agents/schema-utils.test.js.map +1 -0
  31. package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
  32. package/dist/src/agents/subagent-tool-wrapper.js +48 -0
  33. package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
  34. package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
  35. package/dist/src/agents/subagent-tool-wrapper.test.js +110 -0
  36. package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
  37. package/dist/src/agents/types.d.ts +146 -0
  38. package/dist/src/agents/types.js +19 -0
  39. package/dist/src/agents/types.js.map +1 -0
  40. package/dist/src/agents/utils.d.ts +15 -0
  41. package/dist/src/agents/utils.js +29 -0
  42. package/dist/src/agents/utils.js.map +1 -0
  43. package/dist/src/agents/utils.test.d.ts +6 -0
  44. package/dist/src/agents/utils.test.js +87 -0
  45. package/dist/src/agents/utils.test.js.map +1 -0
  46. package/dist/src/code_assist/codeAssist.d.ts +6 -3
  47. package/dist/src/code_assist/codeAssist.js +13 -1
  48. package/dist/src/code_assist/codeAssist.js.map +1 -1
  49. package/dist/src/code_assist/codeAssist.test.d.ts +6 -0
  50. package/dist/src/code_assist/codeAssist.test.js +99 -0
  51. package/dist/src/code_assist/codeAssist.test.js.map +1 -0
  52. package/dist/src/code_assist/converter.d.ts +5 -1
  53. package/dist/src/code_assist/converter.js +39 -5
  54. package/dist/src/code_assist/converter.js.map +1 -1
  55. package/dist/src/code_assist/converter.test.js +112 -0
  56. package/dist/src/code_assist/converter.test.js.map +1 -1
  57. package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
  58. package/dist/src/code_assist/experiments/client_metadata.js +50 -0
  59. package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
  60. package/dist/src/code_assist/experiments/client_metadata.test.d.ts +6 -0
  61. package/dist/src/code_assist/experiments/client_metadata.test.js +99 -0
  62. package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
  63. package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
  64. package/dist/src/code_assist/experiments/experiments.js +36 -0
  65. package/dist/src/code_assist/experiments/experiments.js.map +1 -0
  66. package/dist/src/code_assist/experiments/experiments.test.d.ts +6 -0
  67. package/dist/src/code_assist/experiments/experiments.test.js +92 -0
  68. package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
  69. package/dist/src/code_assist/experiments/flagNames.d.ts +13 -0
  70. package/dist/src/code_assist/experiments/flagNames.js +13 -0
  71. package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
  72. package/dist/src/code_assist/experiments/types.d.ts +35 -0
  73. package/dist/src/code_assist/experiments/types.js +7 -0
  74. package/dist/src/code_assist/experiments/types.js.map +1 -0
  75. package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
  76. package/dist/src/code_assist/oauth-credential-storage.js +110 -0
  77. package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
  78. package/dist/src/code_assist/oauth-credential-storage.test.d.ts +6 -0
  79. package/dist/src/code_assist/oauth-credential-storage.test.js +198 -0
  80. package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
  81. package/dist/src/code_assist/oauth2.d.ts +3 -3
  82. package/dist/src/code_assist/oauth2.js +252 -125
  83. package/dist/src/code_assist/oauth2.js.map +1 -1
  84. package/dist/src/code_assist/oauth2.test.js +788 -350
  85. package/dist/src/code_assist/oauth2.test.js.map +1 -1
  86. package/dist/src/code_assist/server.d.ts +8 -6
  87. package/dist/src/code_assist/server.js +41 -10
  88. package/dist/src/code_assist/server.js.map +1 -1
  89. package/dist/src/code_assist/server.test.js +151 -28
  90. package/dist/src/code_assist/server.test.js.map +1 -1
  91. package/dist/src/code_assist/setup.d.ts +2 -2
  92. package/dist/src/code_assist/setup.js +5 -3
  93. package/dist/src/code_assist/setup.js.map +1 -1
  94. package/dist/src/code_assist/setup.test.js.map +1 -1
  95. package/dist/src/code_assist/types.d.ts +18 -3
  96. package/dist/src/code_assist/types.js.map +1 -1
  97. package/dist/src/commands/extensions.d.ts +7 -0
  98. package/dist/src/commands/extensions.js +9 -0
  99. package/dist/src/commands/extensions.js.map +1 -0
  100. package/dist/src/commands/extensions.test.d.ts +6 -0
  101. package/dist/src/commands/extensions.test.js +19 -0
  102. package/dist/src/commands/extensions.test.js.map +1 -0
  103. package/dist/src/config/config.d.ts +282 -60
  104. package/dist/src/config/config.js +677 -129
  105. package/dist/src/config/config.js.map +1 -1
  106. package/dist/src/config/config.test.js +1020 -146
  107. package/dist/src/config/config.test.js.map +1 -1
  108. package/dist/src/config/constants.d.ts +11 -0
  109. package/dist/src/config/constants.js +16 -0
  110. package/dist/src/config/constants.js.map +1 -0
  111. package/dist/src/config/defaultModelConfigs.d.ts +7 -0
  112. package/dist/src/config/defaultModelConfigs.js +185 -0
  113. package/dist/src/config/defaultModelConfigs.js.map +1 -0
  114. package/dist/src/config/models.d.ts +37 -0
  115. package/dist/src/config/models.js +72 -0
  116. package/dist/src/config/models.js.map +1 -1
  117. package/dist/src/config/models.test.d.ts +6 -0
  118. package/dist/src/config/models.test.js +116 -0
  119. package/dist/src/config/models.test.js.map +1 -0
  120. package/dist/src/config/storage.d.ts +36 -0
  121. package/dist/src/config/storage.js +115 -0
  122. package/dist/src/config/storage.js.map +1 -0
  123. package/dist/src/config/storage.test.d.ts +6 -0
  124. package/dist/src/config/storage.test.js +48 -0
  125. package/dist/src/config/storage.test.js.map +1 -0
  126. package/dist/src/confirmation-bus/index.d.ts +7 -0
  127. package/dist/src/confirmation-bus/index.js +8 -0
  128. package/dist/src/confirmation-bus/index.js.map +1 -0
  129. package/dist/src/confirmation-bus/message-bus.d.ts +18 -0
  130. package/dist/src/confirmation-bus/message-bus.js +87 -0
  131. package/dist/src/confirmation-bus/message-bus.js.map +1 -0
  132. package/dist/src/confirmation-bus/message-bus.test.d.ts +6 -0
  133. package/dist/src/confirmation-bus/message-bus.test.js +170 -0
  134. package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
  135. package/dist/src/confirmation-bus/types.d.ts +49 -0
  136. package/dist/src/confirmation-bus/types.js +16 -0
  137. package/dist/src/confirmation-bus/types.js.map +1 -0
  138. package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
  139. package/dist/src/core/apiKeyCredentialStorage.js +64 -0
  140. package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
  141. package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
  142. package/dist/src/core/apiKeyCredentialStorage.test.js +71 -0
  143. package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
  144. package/dist/src/core/baseLlmClient.d.ts +50 -0
  145. package/dist/src/core/baseLlmClient.js +185 -0
  146. package/dist/src/core/baseLlmClient.js.map +1 -0
  147. package/dist/src/core/baseLlmClient.test.d.ts +6 -0
  148. package/dist/src/core/baseLlmClient.test.js +311 -0
  149. package/dist/src/core/baseLlmClient.test.js.map +1 -0
  150. package/dist/src/core/client.d.ts +30 -42
  151. package/dist/src/core/client.js +178 -477
  152. package/dist/src/core/client.js.map +1 -1
  153. package/dist/src/core/client.test.js +739 -617
  154. package/dist/src/core/client.test.js.map +1 -1
  155. package/dist/src/core/contentGenerator.d.ts +7 -6
  156. package/dist/src/core/contentGenerator.js +59 -45
  157. package/dist/src/core/contentGenerator.js.map +1 -1
  158. package/dist/src/core/contentGenerator.test.js +50 -4
  159. package/dist/src/core/contentGenerator.test.js.map +1 -1
  160. package/dist/src/core/coreToolScheduler.d.ts +28 -11
  161. package/dist/src/core/coreToolScheduler.js +493 -161
  162. package/dist/src/core/coreToolScheduler.js.map +1 -1
  163. package/dist/src/core/coreToolScheduler.test.js +995 -163
  164. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  165. package/dist/src/core/fakeContentGenerator.d.ts +33 -0
  166. package/dist/src/core/fakeContentGenerator.js +58 -0
  167. package/dist/src/core/fakeContentGenerator.js.map +1 -0
  168. package/dist/src/core/fakeContentGenerator.test.d.ts +6 -0
  169. package/dist/src/core/fakeContentGenerator.test.js +127 -0
  170. package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
  171. package/dist/src/core/geminiChat.d.ts +61 -55
  172. package/dist/src/core/geminiChat.js +388 -366
  173. package/dist/src/core/geminiChat.js.map +1 -1
  174. package/dist/src/core/geminiChat.test.js +1600 -355
  175. package/dist/src/core/geminiChat.test.js.map +1 -1
  176. package/dist/src/core/geminiRequest.js +1 -0
  177. package/dist/src/core/geminiRequest.js.map +1 -1
  178. package/dist/src/core/logger.d.ts +11 -4
  179. package/dist/src/core/logger.js +39 -30
  180. package/dist/src/core/logger.js.map +1 -1
  181. package/dist/src/core/logger.test.js +62 -45
  182. package/dist/src/core/logger.test.js.map +1 -1
  183. package/dist/src/core/loggingContentGenerator.d.ts +4 -3
  184. package/dist/src/core/loggingContentGenerator.js +116 -37
  185. package/dist/src/core/loggingContentGenerator.js.map +1 -1
  186. package/dist/src/core/loggingContentGenerator.test.d.ts +6 -0
  187. package/dist/src/core/loggingContentGenerator.test.js +180 -0
  188. package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
  189. package/dist/src/core/nonInteractiveToolExecutor.d.ts +4 -5
  190. package/dist/src/core/nonInteractiveToolExecutor.js +17 -120
  191. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  192. package/dist/src/core/nonInteractiveToolExecutor.test.js +168 -84
  193. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  194. package/dist/src/core/openaiContentGenerator.d.ts +4 -3
  195. package/dist/src/core/openaiContentGenerator.js +49 -19
  196. package/dist/src/core/openaiContentGenerator.js.map +1 -1
  197. package/dist/src/core/openaiContentGenerator.test.js +1 -0
  198. package/dist/src/core/openaiContentGenerator.test.js.map +1 -1
  199. package/dist/src/core/prompts.d.ts +7 -1
  200. package/dist/src/core/prompts.js +198 -195
  201. package/dist/src/core/prompts.js.map +1 -1
  202. package/dist/src/core/prompts.test.js +172 -104
  203. package/dist/src/core/prompts.test.js.map +1 -1
  204. package/dist/src/core/recordingContentGenerator.d.ts +18 -0
  205. package/dist/src/core/recordingContentGenerator.js +77 -0
  206. package/dist/src/core/recordingContentGenerator.js.map +1 -0
  207. package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
  208. package/dist/src/core/recordingContentGenerator.test.js +101 -0
  209. package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
  210. package/dist/src/core/subagent.d.ts +24 -18
  211. package/dist/src/core/subagent.js +125 -90
  212. package/dist/src/core/subagent.js.map +1 -1
  213. package/dist/src/core/subagent.test.js +59 -44
  214. package/dist/src/core/subagent.test.js.map +1 -1
  215. package/dist/src/core/tokenLimits.test.d.ts +6 -0
  216. package/dist/src/core/tokenLimits.test.js +26 -0
  217. package/dist/src/core/tokenLimits.test.js.map +1 -0
  218. package/dist/src/core/turn.d.ts +57 -13
  219. package/dist/src/core/turn.js +79 -35
  220. package/dist/src/core/turn.js.map +1 -1
  221. package/dist/src/core/turn.test.js +373 -120
  222. package/dist/src/core/turn.test.js.map +1 -1
  223. package/dist/src/fallback/handler.d.ts +7 -0
  224. package/dist/src/fallback/handler.js +181 -0
  225. package/dist/src/fallback/handler.js.map +1 -0
  226. package/dist/src/fallback/handler.test.d.ts +6 -0
  227. package/dist/src/fallback/handler.test.js +245 -0
  228. package/dist/src/fallback/handler.test.js.map +1 -0
  229. package/dist/src/fallback/types.d.ts +14 -0
  230. package/dist/src/fallback/types.js +7 -0
  231. package/dist/src/fallback/types.js.map +1 -0
  232. package/dist/src/generated/git-commit.d.ts +2 -2
  233. package/dist/src/generated/git-commit.js +2 -2
  234. package/dist/src/generated/git-commit.js.map +1 -1
  235. package/dist/src/hooks/hookAggregator.d.ts +68 -0
  236. package/dist/src/hooks/hookAggregator.js +262 -0
  237. package/dist/src/hooks/hookAggregator.js.map +1 -0
  238. package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
  239. package/dist/src/hooks/hookAggregator.test.js +387 -0
  240. package/dist/src/hooks/hookAggregator.test.js.map +1 -0
  241. package/dist/src/hooks/hookPlanner.d.ts +46 -0
  242. package/dist/src/hooks/hookPlanner.js +108 -0
  243. package/dist/src/hooks/hookPlanner.js.map +1 -0
  244. package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
  245. package/dist/src/hooks/hookPlanner.test.js +255 -0
  246. package/dist/src/hooks/hookPlanner.test.js.map +1 -0
  247. package/dist/src/hooks/hookRegistry.d.ts +87 -0
  248. package/dist/src/hooks/hookRegistry.js +198 -0
  249. package/dist/src/hooks/hookRegistry.js.map +1 -0
  250. package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
  251. package/dist/src/hooks/hookRegistry.test.js +341 -0
  252. package/dist/src/hooks/hookRegistry.test.js.map +1 -0
  253. package/dist/src/hooks/hookRunner.d.ts +42 -0
  254. package/dist/src/hooks/hookRunner.js +272 -0
  255. package/dist/src/hooks/hookRunner.js.map +1 -0
  256. package/dist/src/hooks/hookRunner.test.d.ts +6 -0
  257. package/dist/src/hooks/hookRunner.test.js +468 -0
  258. package/dist/src/hooks/hookRunner.test.js.map +1 -0
  259. package/dist/src/hooks/hookTranslator.d.ts +113 -0
  260. package/dist/src/hooks/hookTranslator.js +232 -0
  261. package/dist/src/hooks/hookTranslator.js.map +1 -0
  262. package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
  263. package/dist/src/hooks/hookTranslator.test.js +192 -0
  264. package/dist/src/hooks/hookTranslator.test.js.map +1 -0
  265. package/dist/src/hooks/types.d.ts +384 -0
  266. package/dist/src/hooks/types.js +284 -0
  267. package/dist/src/hooks/types.js.map +1 -0
  268. package/dist/src/hooks/types.test.d.ts +6 -0
  269. package/dist/src/hooks/types.test.js +313 -0
  270. package/dist/src/hooks/types.test.js.map +1 -0
  271. package/dist/src/ide/constants.d.ts +3 -0
  272. package/dist/src/ide/constants.js +3 -0
  273. package/dist/src/ide/constants.js.map +1 -1
  274. package/dist/src/ide/detect-ide.d.ts +52 -12
  275. package/dist/src/ide/detect-ide.js +51 -65
  276. package/dist/src/ide/detect-ide.js.map +1 -1
  277. package/dist/src/ide/detect-ide.test.js +95 -52
  278. package/dist/src/ide/detect-ide.test.js.map +1 -1
  279. package/dist/src/ide/ide-client.d.ts +72 -24
  280. package/dist/src/ide/ide-client.js +380 -84
  281. package/dist/src/ide/ide-client.js.map +1 -1
  282. package/dist/src/ide/ide-client.test.js +539 -35
  283. package/dist/src/ide/ide-client.test.js.map +1 -1
  284. package/dist/src/ide/ide-installer.d.ts +2 -2
  285. package/dist/src/ide/ide-installer.js +93 -35
  286. package/dist/src/ide/ide-installer.js.map +1 -1
  287. package/dist/src/ide/ide-installer.test.js +157 -26
  288. package/dist/src/ide/ide-installer.test.js.map +1 -1
  289. package/dist/src/ide/ideContext.d.ts +35 -365
  290. package/dist/src/ide/ideContext.js +60 -106
  291. package/dist/src/ide/ideContext.js.map +1 -1
  292. package/dist/src/ide/ideContext.test.js +152 -24
  293. package/dist/src/ide/ideContext.test.js.map +1 -1
  294. package/dist/src/ide/process-utils.d.ts +7 -5
  295. package/dist/src/ide/process-utils.js +108 -67
  296. package/dist/src/ide/process-utils.js.map +1 -1
  297. package/dist/src/ide/process-utils.test.d.ts +6 -0
  298. package/dist/src/ide/process-utils.test.js +151 -0
  299. package/dist/src/ide/process-utils.test.js.map +1 -0
  300. package/dist/src/ide/types.d.ts +486 -0
  301. package/dist/src/ide/types.js +138 -0
  302. package/dist/src/ide/types.js.map +1 -0
  303. package/dist/src/index.d.ts +41 -2
  304. package/dist/src/index.js +44 -2
  305. package/dist/src/index.js.map +1 -1
  306. package/dist/src/mcp/google-auth-provider.d.ts +5 -3
  307. package/dist/src/mcp/google-auth-provider.js +21 -3
  308. package/dist/src/mcp/google-auth-provider.js.map +1 -1
  309. package/dist/src/mcp/google-auth-provider.test.js +42 -9
  310. package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
  311. package/dist/src/mcp/oauth-provider.d.ts +25 -18
  312. package/dist/src/mcp/oauth-provider.js +194 -97
  313. package/dist/src/mcp/oauth-provider.js.map +1 -1
  314. package/dist/src/mcp/oauth-provider.test.js +581 -39
  315. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  316. package/dist/src/mcp/oauth-token-storage.d.ts +14 -32
  317. package/dist/src/mcp/oauth-token-storage.js +58 -28
  318. package/dist/src/mcp/oauth-token-storage.js.map +1 -1
  319. package/dist/src/mcp/oauth-token-storage.test.js +262 -162
  320. package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
  321. package/dist/src/mcp/oauth-utils.d.ts +16 -1
  322. package/dist/src/mcp/oauth-utils.js +68 -33
  323. package/dist/src/mcp/oauth-utils.js.map +1 -1
  324. package/dist/src/mcp/oauth-utils.test.js +86 -3
  325. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  326. package/dist/src/mcp/sa-impersonation-provider.d.ts +27 -0
  327. package/dist/src/mcp/sa-impersonation-provider.js +113 -0
  328. package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
  329. package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
  330. package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
  331. package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
  332. package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
  333. package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
  334. package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
  335. package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
  336. package/dist/src/mcp/token-storage/base-token-storage.test.js +151 -0
  337. package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
  338. package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
  339. package/dist/src/mcp/token-storage/file-token-storage.js +145 -0
  340. package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
  341. package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
  342. package/dist/src/mcp/token-storage/file-token-storage.test.js +238 -0
  343. package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
  344. package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
  345. package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
  346. package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
  347. package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
  348. package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
  349. package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
  350. package/dist/src/mcp/token-storage/index.d.ts +11 -0
  351. package/dist/src/mcp/token-storage/index.js +12 -0
  352. package/dist/src/mcp/token-storage/index.js.map +1 -0
  353. package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +35 -0
  354. package/dist/src/mcp/token-storage/keychain-token-storage.js +246 -0
  355. package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
  356. package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
  357. package/dist/src/mcp/token-storage/keychain-token-storage.test.js +305 -0
  358. package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
  359. package/dist/src/mcp/token-storage/types.d.ts +44 -0
  360. package/dist/src/mcp/token-storage/types.js +11 -0
  361. package/dist/src/mcp/token-storage/types.js.map +1 -0
  362. package/dist/src/output/json-formatter.d.ts +11 -0
  363. package/dist/src/output/json-formatter.js +30 -0
  364. package/dist/src/output/json-formatter.js.map +1 -0
  365. package/dist/src/output/json-formatter.test.d.ts +6 -0
  366. package/dist/src/output/json-formatter.test.js +266 -0
  367. package/dist/src/output/json-formatter.test.js.map +1 -0
  368. package/dist/src/output/stream-json-formatter.d.ts +32 -0
  369. package/dist/src/output/stream-json-formatter.js +52 -0
  370. package/dist/src/output/stream-json-formatter.js.map +1 -0
  371. package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
  372. package/dist/src/output/stream-json-formatter.test.js +479 -0
  373. package/dist/src/output/stream-json-formatter.test.js.map +1 -0
  374. package/dist/src/output/types.d.ts +82 -0
  375. package/dist/src/output/types.js +22 -0
  376. package/dist/src/output/types.js.map +1 -0
  377. package/dist/src/policy/config.d.ts +31 -0
  378. package/dist/src/policy/config.js +199 -0
  379. package/dist/src/policy/config.js.map +1 -0
  380. package/dist/src/policy/config.test.d.ts +6 -0
  381. package/dist/src/policy/config.test.js +538 -0
  382. package/dist/src/policy/config.test.js.map +1 -0
  383. package/dist/src/policy/index.d.ts +9 -0
  384. package/dist/src/policy/index.js +10 -0
  385. package/dist/src/policy/index.js.map +1 -0
  386. package/dist/src/policy/policies/discovered.toml +8 -0
  387. package/dist/src/policy/policies/read-only.toml +56 -0
  388. package/dist/src/policy/policies/write.toml +73 -0
  389. package/dist/src/policy/policies/yolo.toml +31 -0
  390. package/dist/src/policy/policy-engine.d.ts +39 -0
  391. package/dist/src/policy/policy-engine.js +158 -0
  392. package/dist/src/policy/policy-engine.js.map +1 -0
  393. package/dist/src/policy/policy-engine.test.d.ts +6 -0
  394. package/dist/src/policy/policy-engine.test.js +899 -0
  395. package/dist/src/policy/policy-engine.test.js.map +1 -0
  396. package/dist/src/policy/stable-stringify.d.ts +58 -0
  397. package/dist/src/policy/stable-stringify.js +122 -0
  398. package/dist/src/policy/stable-stringify.js.map +1 -0
  399. package/dist/src/policy/toml-loader.d.ts +47 -0
  400. package/dist/src/policy/toml-loader.js +411 -0
  401. package/dist/src/policy/toml-loader.js.map +1 -0
  402. package/dist/src/policy/toml-loader.test.d.ts +6 -0
  403. package/dist/src/policy/toml-loader.test.js +376 -0
  404. package/dist/src/policy/toml-loader.test.js.map +1 -0
  405. package/dist/src/policy/types.d.ts +130 -0
  406. package/dist/src/policy/types.js +22 -0
  407. package/dist/src/policy/types.js.map +1 -0
  408. package/dist/src/prompts/mcp-prompts.d.ts +2 -2
  409. package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
  410. package/dist/src/prompts/mcp-prompts.test.js +39 -0
  411. package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
  412. package/dist/src/prompts/prompt-registry.d.ts +1 -1
  413. package/dist/src/prompts/prompt-registry.js +2 -1
  414. package/dist/src/prompts/prompt-registry.js.map +1 -1
  415. package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
  416. package/dist/src/prompts/prompt-registry.test.js +96 -0
  417. package/dist/src/prompts/prompt-registry.test.js.map +1 -0
  418. package/dist/src/routing/modelRouterService.d.ts +23 -0
  419. package/dist/src/routing/modelRouterService.js +85 -0
  420. package/dist/src/routing/modelRouterService.js.map +1 -0
  421. package/dist/src/routing/modelRouterService.test.d.ts +6 -0
  422. package/dist/src/routing/modelRouterService.test.js +160 -0
  423. package/dist/src/routing/modelRouterService.test.js.map +1 -0
  424. package/dist/src/routing/routingStrategy.d.ts +62 -0
  425. package/dist/src/routing/routingStrategy.js +7 -0
  426. package/dist/src/routing/routingStrategy.js.map +1 -0
  427. package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
  428. package/dist/src/routing/strategies/classifierStrategy.js +166 -0
  429. package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
  430. package/dist/src/routing/strategies/classifierStrategy.test.d.ts +6 -0
  431. package/dist/src/routing/strategies/classifierStrategy.test.js +196 -0
  432. package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
  433. package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
  434. package/dist/src/routing/strategies/compositeStrategy.js +68 -0
  435. package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
  436. package/dist/src/routing/strategies/compositeStrategy.test.d.ts +6 -0
  437. package/dist/src/routing/strategies/compositeStrategy.test.js +123 -0
  438. package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
  439. package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
  440. package/dist/src/routing/strategies/defaultStrategy.js +20 -0
  441. package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
  442. package/dist/src/routing/strategies/defaultStrategy.test.d.ts +6 -0
  443. package/dist/src/routing/strategies/defaultStrategy.test.js +26 -0
  444. package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
  445. package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
  446. package/dist/src/routing/strategies/fallbackStrategy.js +25 -0
  447. package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
  448. package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +6 -0
  449. package/dist/src/routing/strategies/fallbackStrategy.test.js +59 -0
  450. package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
  451. package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
  452. package/dist/src/routing/strategies/overrideStrategy.js +28 -0
  453. package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
  454. package/dist/src/routing/strategies/overrideStrategy.test.d.ts +6 -0
  455. package/dist/src/routing/strategies/overrideStrategy.test.js +45 -0
  456. package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
  457. package/dist/src/safety/built-in.d.ts +21 -0
  458. package/dist/src/safety/built-in.js +106 -0
  459. package/dist/src/safety/built-in.js.map +1 -0
  460. package/dist/src/safety/built-in.test.d.ts +6 -0
  461. package/dist/src/safety/built-in.test.js +199 -0
  462. package/dist/src/safety/built-in.test.js.map +1 -0
  463. package/dist/src/safety/checker-runner.d.ts +48 -0
  464. package/dist/src/safety/checker-runner.js +208 -0
  465. package/dist/src/safety/checker-runner.js.map +1 -0
  466. package/dist/src/safety/checker-runner.test.d.ts +6 -0
  467. package/dist/src/safety/checker-runner.test.js +238 -0
  468. package/dist/src/safety/checker-runner.test.js.map +1 -0
  469. package/dist/src/safety/context-builder.d.ts +23 -0
  470. package/dist/src/safety/context-builder.js +47 -0
  471. package/dist/src/safety/context-builder.js.map +1 -0
  472. package/dist/src/safety/context-builder.test.d.ts +6 -0
  473. package/dist/src/safety/context-builder.test.js +49 -0
  474. package/dist/src/safety/context-builder.test.js.map +1 -0
  475. package/dist/src/safety/protocol.d.ts +88 -0
  476. package/dist/src/safety/protocol.js +15 -0
  477. package/dist/src/safety/protocol.js.map +1 -0
  478. package/dist/src/safety/registry.d.ts +26 -0
  479. package/dist/src/safety/registry.js +65 -0
  480. package/dist/src/safety/registry.js.map +1 -0
  481. package/dist/src/safety/registry.test.d.ts +6 -0
  482. package/dist/src/safety/registry.test.js +31 -0
  483. package/dist/src/safety/registry.test.js.map +1 -0
  484. package/dist/src/services/chatCompressionService.d.ts +32 -0
  485. package/dist/src/services/chatCompressionService.js +162 -0
  486. package/dist/src/services/chatCompressionService.js.map +1 -0
  487. package/dist/src/services/chatCompressionService.test.d.ts +6 -0
  488. package/dist/src/services/chatCompressionService.test.js +210 -0
  489. package/dist/src/services/chatCompressionService.test.js.map +1 -0
  490. package/dist/src/services/chatRecordingService.d.ts +10 -15
  491. package/dist/src/services/chatRecordingService.js +43 -29
  492. package/dist/src/services/chatRecordingService.js.map +1 -1
  493. package/dist/src/services/chatRecordingService.test.js +69 -25
  494. package/dist/src/services/chatRecordingService.test.js.map +1 -1
  495. package/dist/src/services/fileDiscoveryService.d.ts +8 -10
  496. package/dist/src/services/fileDiscoveryService.js +31 -53
  497. package/dist/src/services/fileDiscoveryService.js.map +1 -1
  498. package/dist/src/services/fileDiscoveryService.test.js +94 -14
  499. package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
  500. package/dist/src/services/fileSystemService.d.ts +9 -0
  501. package/dist/src/services/fileSystemService.js +12 -1
  502. package/dist/src/services/fileSystemService.js.map +1 -1
  503. package/dist/src/services/fileSystemService.test.js +1 -1
  504. package/dist/src/services/fileSystemService.test.js.map +1 -1
  505. package/dist/src/services/gitService.d.ts +3 -1
  506. package/dist/src/services/gitService.js +30 -24
  507. package/dist/src/services/gitService.js.map +1 -1
  508. package/dist/src/services/gitService.test.js +30 -37
  509. package/dist/src/services/gitService.test.js.map +1 -1
  510. package/dist/src/services/loopDetectionService.d.ts +12 -3
  511. package/dist/src/services/loopDetectionService.js +148 -55
  512. package/dist/src/services/loopDetectionService.js.map +1 -1
  513. package/dist/src/services/loopDetectionService.test.js +280 -21
  514. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  515. package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
  516. package/dist/src/services/modelConfig.golden.test.js +42 -0
  517. package/dist/src/services/modelConfig.golden.test.js.map +1 -0
  518. package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
  519. package/dist/src/services/modelConfig.integration.test.js +247 -0
  520. package/dist/src/services/modelConfig.integration.test.js.map +1 -0
  521. package/dist/src/services/modelConfigService.d.ts +48 -0
  522. package/dist/src/services/modelConfigService.js +151 -0
  523. package/dist/src/services/modelConfigService.js.map +1 -0
  524. package/dist/src/services/modelConfigService.test.d.ts +6 -0
  525. package/dist/src/services/modelConfigService.test.js +531 -0
  526. package/dist/src/services/modelConfigService.test.js.map +1 -0
  527. package/dist/src/services/shellExecutionService.d.ts +37 -2
  528. package/dist/src/services/shellExecutionService.js +361 -67
  529. package/dist/src/services/shellExecutionService.js.map +1 -1
  530. package/dist/src/services/shellExecutionService.test.js +333 -71
  531. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  532. package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
  533. package/dist/src/telemetry/activity-detector.d.ts +41 -0
  534. package/dist/src/telemetry/activity-detector.js +61 -0
  535. package/dist/src/telemetry/activity-detector.js.map +1 -0
  536. package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
  537. package/dist/src/telemetry/activity-detector.test.js +136 -0
  538. package/dist/src/telemetry/activity-detector.test.js.map +1 -0
  539. package/dist/src/telemetry/activity-monitor.d.ts +116 -0
  540. package/dist/src/telemetry/activity-monitor.js +209 -0
  541. package/dist/src/telemetry/activity-monitor.js.map +1 -0
  542. package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
  543. package/dist/src/telemetry/activity-monitor.test.js +251 -0
  544. package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
  545. package/dist/src/telemetry/activity-types.d.ts +19 -0
  546. package/dist/src/telemetry/activity-types.js +21 -0
  547. package/dist/src/telemetry/activity-types.js.map +1 -0
  548. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +53 -5
  549. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +581 -56
  550. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  551. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +2 -0
  552. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +467 -31
  553. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  554. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +75 -4
  555. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +182 -6
  556. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  557. package/dist/src/telemetry/config.d.ts +31 -0
  558. package/dist/src/telemetry/config.js +76 -0
  559. package/dist/src/telemetry/config.js.map +1 -0
  560. package/dist/src/telemetry/config.test.d.ts +6 -0
  561. package/dist/src/telemetry/config.test.js +124 -0
  562. package/dist/src/telemetry/config.test.js.map +1 -0
  563. package/dist/src/telemetry/constants.d.ts +0 -18
  564. package/dist/src/telemetry/constants.js +0 -18
  565. package/dist/src/telemetry/constants.js.map +1 -1
  566. package/dist/src/telemetry/file-exporters.d.ts +5 -4
  567. package/dist/src/telemetry/file-exporters.js +1 -1
  568. package/dist/src/telemetry/file-exporters.js.map +1 -1
  569. package/dist/src/telemetry/gcp-exporters.d.ts +34 -0
  570. package/dist/src/telemetry/gcp-exporters.js +116 -0
  571. package/dist/src/telemetry/gcp-exporters.js.map +1 -0
  572. package/dist/src/telemetry/gcp-exporters.test.d.ts +6 -0
  573. package/dist/src/telemetry/gcp-exporters.test.js +318 -0
  574. package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
  575. package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
  576. package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
  577. package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
  578. package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +6 -0
  579. package/dist/src/telemetry/high-water-mark-tracker.test.js +152 -0
  580. package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
  581. package/dist/src/telemetry/index.d.ts +16 -2
  582. package/dist/src/telemetry/index.js +25 -2
  583. package/dist/src/telemetry/index.js.map +1 -1
  584. package/dist/src/telemetry/loggers.d.ts +25 -3
  585. package/dist/src/telemetry/loggers.js +333 -154
  586. package/dist/src/telemetry/loggers.js.map +1 -1
  587. package/dist/src/telemetry/loggers.test.circular.js +3 -4
  588. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  589. package/dist/src/telemetry/loggers.test.js +868 -63
  590. package/dist/src/telemetry/loggers.test.js.map +1 -1
  591. package/dist/src/telemetry/memory-monitor.d.ts +149 -0
  592. package/dist/src/telemetry/memory-monitor.js +335 -0
  593. package/dist/src/telemetry/memory-monitor.js.map +1 -0
  594. package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
  595. package/dist/src/telemetry/memory-monitor.test.js +472 -0
  596. package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
  597. package/dist/src/telemetry/metrics.d.ts +498 -11
  598. package/dist/src/telemetry/metrics.js +729 -84
  599. package/dist/src/telemetry/metrics.js.map +1 -1
  600. package/dist/src/telemetry/metrics.test.js +964 -101
  601. package/dist/src/telemetry/metrics.test.js.map +1 -1
  602. package/dist/src/telemetry/rate-limiter.d.ts +48 -0
  603. package/dist/src/telemetry/rate-limiter.js +100 -0
  604. package/dist/src/telemetry/rate-limiter.js.map +1 -0
  605. package/dist/src/telemetry/rate-limiter.test.d.ts +6 -0
  606. package/dist/src/telemetry/rate-limiter.test.js +207 -0
  607. package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
  608. package/dist/src/telemetry/sdk.d.ts +1 -1
  609. package/dist/src/telemetry/sdk.js +23 -4
  610. package/dist/src/telemetry/sdk.js.map +1 -1
  611. package/dist/src/telemetry/sdk.test.js +108 -0
  612. package/dist/src/telemetry/sdk.test.js.map +1 -1
  613. package/dist/src/telemetry/semantic.d.ts +82 -0
  614. package/dist/src/telemetry/semantic.js +269 -0
  615. package/dist/src/telemetry/semantic.js.map +1 -0
  616. package/dist/src/telemetry/semantic.test.d.ts +6 -0
  617. package/dist/src/telemetry/semantic.test.js +387 -0
  618. package/dist/src/telemetry/semantic.test.js.map +1 -0
  619. package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
  620. package/dist/src/telemetry/telemetry-utils.js +14 -0
  621. package/dist/src/telemetry/telemetry-utils.js.map +1 -0
  622. package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
  623. package/dist/src/telemetry/telemetry-utils.test.js +41 -0
  624. package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
  625. package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
  626. package/dist/src/telemetry/telemetryAttributes.js +19 -0
  627. package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
  628. package/dist/src/telemetry/trace.d.ts +46 -0
  629. package/dist/src/telemetry/trace.js +121 -0
  630. package/dist/src/telemetry/trace.js.map +1 -0
  631. package/dist/src/telemetry/types.d.ts +351 -25
  632. package/dist/src/telemetry/types.js +1071 -63
  633. package/dist/src/telemetry/types.js.map +1 -1
  634. package/dist/src/telemetry/uiTelemetry.d.ts +4 -4
  635. package/dist/src/telemetry/uiTelemetry.js +14 -15
  636. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  637. package/dist/src/telemetry/uiTelemetry.test.js +122 -96
  638. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  639. package/dist/src/test-utils/config.d.ts +3 -2
  640. package/dist/src/test-utils/config.js +1 -1
  641. package/dist/src/test-utils/config.js.map +1 -1
  642. package/dist/src/test-utils/index.d.ts +6 -0
  643. package/dist/src/test-utils/index.js +7 -0
  644. package/dist/src/test-utils/index.js.map +1 -0
  645. package/dist/src/test-utils/mock-tool.d.ts +66 -0
  646. package/dist/src/test-utils/{tools.js → mock-tool.js} +45 -29
  647. package/dist/src/test-utils/mock-tool.js.map +1 -0
  648. package/dist/src/test-utils/mockWorkspaceContext.d.ts +1 -1
  649. package/dist/src/tools/base-tool-invocation.test.d.ts +6 -0
  650. package/dist/src/tools/base-tool-invocation.test.js +85 -0
  651. package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
  652. package/dist/src/tools/diffOptions.d.ts +1 -1
  653. package/dist/src/tools/diffOptions.js +21 -13
  654. package/dist/src/tools/diffOptions.js.map +1 -1
  655. package/dist/src/tools/diffOptions.test.js +58 -22
  656. package/dist/src/tools/diffOptions.test.js.map +1 -1
  657. package/dist/src/tools/edit.d.ts +10 -8
  658. package/dist/src/tools/edit.js +100 -79
  659. package/dist/src/tools/edit.js.map +1 -1
  660. package/dist/src/tools/edit.test.js +429 -163
  661. package/dist/src/tools/edit.test.js.map +1 -1
  662. package/dist/src/tools/glob.d.ts +11 -5
  663. package/dist/src/tools/glob.js +58 -42
  664. package/dist/src/tools/glob.js.map +1 -1
  665. package/dist/src/tools/glob.test.js +249 -166
  666. package/dist/src/tools/glob.test.js.map +1 -1
  667. package/dist/src/tools/grep.d.ts +7 -5
  668. package/dist/src/tools/grep.js +66 -40
  669. package/dist/src/tools/grep.js.map +1 -1
  670. package/dist/src/tools/grep.test.js +41 -15
  671. package/dist/src/tools/grep.test.js.map +1 -1
  672. package/dist/src/tools/ls.d.ts +7 -5
  673. package/dist/src/tools/ls.js +54 -68
  674. package/dist/src/tools/ls.js.map +1 -1
  675. package/dist/src/tools/ls.test.js +150 -293
  676. package/dist/src/tools/ls.test.js.map +1 -1
  677. package/dist/src/tools/mcp-client-manager.d.ts +52 -12
  678. package/dist/src/tools/mcp-client-manager.js +196 -27
  679. package/dist/src/tools/mcp-client-manager.js.map +1 -1
  680. package/dist/src/tools/mcp-client-manager.test.js +139 -13
  681. package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
  682. package/dist/src/tools/mcp-client.d.ts +28 -24
  683. package/dist/src/tools/mcp-client.js +338 -351
  684. package/dist/src/tools/mcp-client.js.map +1 -1
  685. package/dist/src/tools/mcp-client.test.js +380 -193
  686. package/dist/src/tools/mcp-client.test.js.map +1 -1
  687. package/dist/src/tools/mcp-tool.d.ts +11 -5
  688. package/dist/src/tools/mcp-tool.js +66 -17
  689. package/dist/src/tools/mcp-tool.js.map +1 -1
  690. package/dist/src/tools/mcp-tool.test.js +278 -211
  691. package/dist/src/tools/mcp-tool.test.js.map +1 -1
  692. package/dist/src/tools/memoryTool.d.ts +10 -7
  693. package/dist/src/tools/memoryTool.js +28 -49
  694. package/dist/src/tools/memoryTool.js.map +1 -1
  695. package/dist/src/tools/memoryTool.test.js +26 -13
  696. package/dist/src/tools/memoryTool.test.js.map +1 -1
  697. package/dist/src/tools/message-bus-integration.test.d.ts +6 -0
  698. package/dist/src/tools/message-bus-integration.test.js +196 -0
  699. package/dist/src/tools/message-bus-integration.test.js.map +1 -0
  700. package/dist/src/tools/modifiable-tool.d.ts +7 -3
  701. package/dist/src/tools/modifiable-tool.js +41 -19
  702. package/dist/src/tools/modifiable-tool.js.map +1 -1
  703. package/dist/src/tools/modifiable-tool.test.js +70 -35
  704. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  705. package/dist/src/tools/read-file.d.ts +9 -7
  706. package/dist/src/tools/read-file.js +39 -60
  707. package/dist/src/tools/read-file.js.map +1 -1
  708. package/dist/src/tools/read-file.test.js +103 -36
  709. package/dist/src/tools/read-file.test.js.map +1 -1
  710. package/dist/src/tools/read-many-files.d.ts +9 -14
  711. package/dist/src/tools/read-many-files.js +71 -155
  712. package/dist/src/tools/read-many-files.js.map +1 -1
  713. package/dist/src/tools/read-many-files.test.js +98 -44
  714. package/dist/src/tools/read-many-files.test.js.map +1 -1
  715. package/dist/src/tools/ripGrep.d.ts +73 -0
  716. package/dist/src/tools/ripGrep.js +395 -0
  717. package/dist/src/tools/ripGrep.js.map +1 -0
  718. package/dist/src/tools/ripGrep.test.d.ts +6 -0
  719. package/dist/src/tools/ripGrep.test.js +1305 -0
  720. package/dist/src/tools/ripGrep.test.js.map +1 -0
  721. package/dist/src/tools/shell.d.ts +19 -6
  722. package/dist/src/tools/shell.js +92 -56
  723. package/dist/src/tools/shell.js.map +1 -1
  724. package/dist/src/tools/shell.test.js +176 -103
  725. package/dist/src/tools/shell.test.js.map +1 -1
  726. package/dist/src/tools/smart-edit.d.ts +78 -0
  727. package/dist/src/tools/smart-edit.js +717 -0
  728. package/dist/src/tools/smart-edit.js.map +1 -0
  729. package/dist/src/tools/smart-edit.test.d.ts +6 -0
  730. package/dist/src/tools/smart-edit.test.js +592 -0
  731. package/dist/src/tools/smart-edit.test.js.map +1 -0
  732. package/dist/src/tools/tool-error.d.ts +39 -1
  733. package/dist/src/tools/tool-error.js +54 -0
  734. package/dist/src/tools/tool-error.js.map +1 -1
  735. package/dist/src/tools/tool-names.d.ts +17 -0
  736. package/dist/src/tools/tool-names.js +21 -0
  737. package/dist/src/tools/tool-names.js.map +1 -0
  738. package/dist/src/tools/tool-registry.d.ts +38 -20
  739. package/dist/src/tools/tool-registry.js +134 -77
  740. package/dist/src/tools/tool-registry.js.map +1 -1
  741. package/dist/src/tools/tool-registry.test.js +218 -58
  742. package/dist/src/tools/tool-registry.test.js.map +1 -1
  743. package/dist/src/tools/tools.d.ts +49 -17
  744. package/dist/src/tools/tools.js +150 -8
  745. package/dist/src/tools/tools.js.map +1 -1
  746. package/dist/src/tools/tools.test.js +1 -2
  747. package/dist/src/tools/tools.test.js.map +1 -1
  748. package/dist/src/tools/web-fetch.d.ts +14 -5
  749. package/dist/src/tools/web-fetch.js +90 -44
  750. package/dist/src/tools/web-fetch.js.map +1 -1
  751. package/dist/src/tools/web-fetch.test.js +388 -20
  752. package/dist/src/tools/web-fetch.test.js.map +1 -1
  753. package/dist/src/tools/web-search.d.ts +8 -6
  754. package/dist/src/tools/web-search.js +40 -15
  755. package/dist/src/tools/web-search.js.map +1 -1
  756. package/dist/src/tools/web-search.test.js +75 -1
  757. package/dist/src/tools/web-search.test.js.map +1 -1
  758. package/dist/src/tools/write-file.d.ts +7 -5
  759. package/dist/src/tools/write-file.js +54 -54
  760. package/dist/src/tools/write-file.js.map +1 -1
  761. package/dist/src/tools/write-file.test.js +237 -146
  762. package/dist/src/tools/write-file.test.js.map +1 -1
  763. package/dist/src/tools/write-todos.d.ts +50 -0
  764. package/dist/src/tools/write-todos.js +193 -0
  765. package/dist/src/tools/write-todos.js.map +1 -0
  766. package/dist/src/tools/write-todos.test.d.ts +6 -0
  767. package/dist/src/tools/write-todos.test.js +89 -0
  768. package/dist/src/tools/write-todos.test.js.map +1 -0
  769. package/dist/src/utils/bfsFileSearch.d.ts +2 -2
  770. package/dist/src/utils/bfsFileSearch.js +16 -9
  771. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  772. package/dist/src/utils/bfsFileSearch.test.js +3 -3
  773. package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
  774. package/dist/src/utils/channel.d.ts +19 -0
  775. package/dist/src/utils/channel.js +49 -0
  776. package/dist/src/utils/channel.js.map +1 -0
  777. package/dist/src/utils/channel.test.d.ts +6 -0
  778. package/dist/src/utils/channel.test.js +170 -0
  779. package/dist/src/utils/channel.test.js.map +1 -0
  780. package/dist/src/utils/debugLogger.d.ts +25 -0
  781. package/dist/src/utils/debugLogger.js +33 -0
  782. package/dist/src/utils/debugLogger.js.map +1 -0
  783. package/dist/src/utils/debugLogger.test.d.ts +6 -0
  784. package/dist/src/utils/debugLogger.test.js +69 -0
  785. package/dist/src/utils/debugLogger.test.js.map +1 -0
  786. package/dist/src/utils/delay.d.ts +16 -0
  787. package/dist/src/utils/delay.js +43 -0
  788. package/dist/src/utils/delay.js.map +1 -0
  789. package/dist/src/utils/delay.test.d.ts +6 -0
  790. package/dist/src/utils/delay.test.js +88 -0
  791. package/dist/src/utils/delay.test.js.map +1 -0
  792. package/dist/src/utils/editCorrector.d.ts +9 -8
  793. package/dist/src/utils/editCorrector.js +62 -34
  794. package/dist/src/utils/editCorrector.js.map +1 -1
  795. package/dist/src/utils/editCorrector.test.js +52 -87
  796. package/dist/src/utils/editCorrector.test.js.map +1 -1
  797. package/dist/src/utils/editor.d.ts +4 -2
  798. package/dist/src/utils/editor.js +56 -55
  799. package/dist/src/utils/editor.js.map +1 -1
  800. package/dist/src/utils/editor.test.js +47 -88
  801. package/dist/src/utils/editor.test.js.map +1 -1
  802. package/dist/src/utils/environmentContext.d.ts +3 -2
  803. package/dist/src/utils/environmentContext.js +20 -33
  804. package/dist/src/utils/environmentContext.js.map +1 -1
  805. package/dist/src/utils/environmentContext.test.js +6 -34
  806. package/dist/src/utils/environmentContext.test.js.map +1 -1
  807. package/dist/src/utils/errorParsing.d.ts +1 -1
  808. package/dist/src/utils/errorParsing.js +5 -33
  809. package/dist/src/utils/errorParsing.js.map +1 -1
  810. package/dist/src/utils/errorParsing.test.js +0 -88
  811. package/dist/src/utils/errorParsing.test.js.map +1 -1
  812. package/dist/src/utils/errorReporting.d.ts +1 -1
  813. package/dist/src/utils/errors.d.ts +28 -0
  814. package/dist/src/utils/errors.js +48 -0
  815. package/dist/src/utils/errors.js.map +1 -1
  816. package/dist/src/utils/events.d.ts +121 -0
  817. package/dist/src/utils/events.js +84 -0
  818. package/dist/src/utils/events.js.map +1 -0
  819. package/dist/src/utils/events.test.d.ts +6 -0
  820. package/dist/src/utils/events.test.js +212 -0
  821. package/dist/src/utils/events.test.js.map +1 -0
  822. package/dist/src/utils/extensionLoader.d.ts +86 -0
  823. package/dist/src/utils/extensionLoader.js +208 -0
  824. package/dist/src/utils/extensionLoader.js.map +1 -0
  825. package/dist/src/utils/extensionLoader.test.d.ts +6 -0
  826. package/dist/src/utils/extensionLoader.test.js +154 -0
  827. package/dist/src/utils/extensionLoader.test.js.map +1 -0
  828. package/dist/src/utils/fetch.d.ts +1 -0
  829. package/dist/src/utils/fetch.js +5 -1
  830. package/dist/src/utils/fetch.js.map +1 -1
  831. package/dist/src/utils/fileUtils.d.ts +28 -12
  832. package/dist/src/utils/fileUtils.js +204 -81
  833. package/dist/src/utils/fileUtils.js.map +1 -1
  834. package/dist/src/utils/fileUtils.test.js +426 -82
  835. package/dist/src/utils/fileUtils.test.js.map +1 -1
  836. package/dist/src/utils/filesearch/crawler.d.ts +1 -1
  837. package/dist/src/utils/filesearch/crawler.test.js +2 -2
  838. package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
  839. package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
  840. package/dist/src/utils/filesearch/fileSearch.js +14 -9
  841. package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
  842. package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
  843. package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
  844. package/dist/src/utils/flashFallback.test.d.ts +6 -0
  845. package/dist/src/utils/flashFallback.test.js +103 -0
  846. package/dist/src/utils/flashFallback.test.js.map +1 -0
  847. package/dist/src/utils/formatters.d.ts +1 -0
  848. package/dist/src/utils/formatters.js +2 -1
  849. package/dist/src/utils/formatters.js.map +1 -1
  850. package/dist/src/utils/formatters.test.d.ts +6 -0
  851. package/dist/src/utils/formatters.test.js +26 -0
  852. package/dist/src/utils/formatters.test.js.map +1 -0
  853. package/dist/src/utils/geminiIgnoreParser.d.ts +18 -0
  854. package/dist/src/utils/geminiIgnoreParser.js +61 -0
  855. package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
  856. package/dist/src/utils/geminiIgnoreParser.test.d.ts +6 -0
  857. package/dist/src/utils/geminiIgnoreParser.test.js +50 -0
  858. package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
  859. package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
  860. package/dist/src/utils/generateContentResponseUtilities.js +1 -13
  861. package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
  862. package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
  863. package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
  864. package/dist/src/utils/getFolderStructure.d.ts +2 -2
  865. package/dist/src/utils/getFolderStructure.js +12 -20
  866. package/dist/src/utils/getFolderStructure.js.map +1 -1
  867. package/dist/src/utils/getFolderStructure.test.js +11 -10
  868. package/dist/src/utils/getFolderStructure.test.js.map +1 -1
  869. package/dist/src/utils/gitIgnoreParser.d.ts +7 -8
  870. package/dist/src/utils/gitIgnoreParser.js +145 -36
  871. package/dist/src/utils/gitIgnoreParser.js.map +1 -1
  872. package/dist/src/utils/gitIgnoreParser.test.js +127 -38
  873. package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
  874. package/dist/src/utils/gitUtils.js +2 -2
  875. package/dist/src/utils/gitUtils.js.map +1 -1
  876. package/dist/src/utils/googleErrors.d.ts +104 -0
  877. package/dist/src/utils/googleErrors.js +152 -0
  878. package/dist/src/utils/googleErrors.js.map +1 -0
  879. package/dist/src/utils/googleErrors.test.d.ts +6 -0
  880. package/dist/src/utils/googleErrors.test.js +301 -0
  881. package/dist/src/utils/googleErrors.test.js.map +1 -0
  882. package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
  883. package/dist/src/utils/googleQuotaErrors.js +157 -0
  884. package/dist/src/utils/googleQuotaErrors.js.map +1 -0
  885. package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
  886. package/dist/src/utils/googleQuotaErrors.test.js +311 -0
  887. package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
  888. package/dist/src/utils/httpErrors.d.ts +18 -0
  889. package/dist/src/utils/httpErrors.js +36 -0
  890. package/dist/src/utils/httpErrors.js.map +1 -0
  891. package/dist/src/utils/ignorePatterns.d.ts +103 -0
  892. package/dist/src/utils/ignorePatterns.js +220 -0
  893. package/dist/src/utils/ignorePatterns.js.map +1 -0
  894. package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
  895. package/dist/src/utils/ignorePatterns.test.js +246 -0
  896. package/dist/src/utils/ignorePatterns.test.js.map +1 -0
  897. package/dist/src/utils/installationManager.d.ts +16 -0
  898. package/dist/src/utils/installationManager.js +51 -0
  899. package/dist/src/utils/installationManager.js.map +1 -0
  900. package/dist/src/utils/installationManager.test.d.ts +6 -0
  901. package/dist/src/utils/installationManager.test.js +85 -0
  902. package/dist/src/utils/installationManager.test.js.map +1 -0
  903. package/dist/src/utils/language-detection.d.ts +6 -0
  904. package/dist/src/utils/language-detection.js +101 -0
  905. package/dist/src/utils/language-detection.js.map +1 -0
  906. package/dist/src/utils/llm-edit-fixer.d.ts +26 -0
  907. package/dist/src/utils/llm-edit-fixer.js +155 -0
  908. package/dist/src/utils/llm-edit-fixer.js.map +1 -0
  909. package/dist/src/utils/llm-edit-fixer.test.d.ts +6 -0
  910. package/dist/src/utils/llm-edit-fixer.test.js +223 -0
  911. package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
  912. package/dist/src/utils/memoryDiscovery.d.ts +26 -6
  913. package/dist/src/utils/memoryDiscovery.js +239 -40
  914. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  915. package/dist/src/utils/memoryDiscovery.test.js +365 -44
  916. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  917. package/dist/src/utils/memoryImportProcessor.js +19 -25
  918. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  919. package/dist/src/utils/memoryImportProcessor.test.js +24 -155
  920. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  921. package/dist/src/utils/messageInspectors.d.ts +1 -1
  922. package/dist/src/utils/nextSpeakerChecker.d.ts +3 -3
  923. package/dist/src/utils/nextSpeakerChecker.js +10 -4
  924. package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
  925. package/dist/src/utils/nextSpeakerChecker.test.js +85 -66
  926. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  927. package/dist/src/utils/package.d.ts +12 -0
  928. package/dist/src/utils/package.js +15 -0
  929. package/dist/src/utils/package.js.map +1 -0
  930. package/dist/src/utils/partUtils.d.ts +22 -1
  931. package/dist/src/utils/partUtils.js +68 -0
  932. package/dist/src/utils/partUtils.js.map +1 -1
  933. package/dist/src/utils/partUtils.test.js +112 -1
  934. package/dist/src/utils/partUtils.test.js.map +1 -1
  935. package/dist/src/utils/pathCorrector.d.ts +25 -0
  936. package/dist/src/utils/pathCorrector.js +33 -0
  937. package/dist/src/utils/pathCorrector.js.map +1 -0
  938. package/dist/src/utils/pathCorrector.test.d.ts +6 -0
  939. package/dist/src/utils/pathCorrector.test.js +83 -0
  940. package/dist/src/utils/pathCorrector.test.js.map +1 -0
  941. package/dist/src/utils/pathReader.d.ts +17 -0
  942. package/dist/src/utils/pathReader.js +92 -0
  943. package/dist/src/utils/pathReader.js.map +1 -0
  944. package/dist/src/utils/pathReader.test.d.ts +6 -0
  945. package/dist/src/utils/pathReader.test.js +406 -0
  946. package/dist/src/utils/pathReader.test.js.map +1 -0
  947. package/dist/src/utils/paths.d.ts +1 -18
  948. package/dist/src/utils/paths.js +133 -57
  949. package/dist/src/utils/paths.js.map +1 -1
  950. package/dist/src/utils/paths.test.js +200 -68
  951. package/dist/src/utils/paths.test.js.map +1 -1
  952. package/dist/src/utils/promptIdContext.d.ts +7 -0
  953. package/dist/src/utils/promptIdContext.js +8 -0
  954. package/dist/src/utils/promptIdContext.js.map +1 -0
  955. package/dist/src/utils/quotaErrorDetection.d.ts +1 -3
  956. package/dist/src/utils/quotaErrorDetection.js +0 -46
  957. package/dist/src/utils/quotaErrorDetection.js.map +1 -1
  958. package/dist/src/utils/retry.d.ts +5 -10
  959. package/dist/src/utils/retry.js +114 -197
  960. package/dist/src/utils/retry.js.map +1 -1
  961. package/dist/src/utils/retry.test.js +196 -130
  962. package/dist/src/utils/retry.test.js.map +1 -1
  963. package/dist/src/utils/safeJsonStringify.d.ts +4 -4
  964. package/dist/src/utils/safeJsonStringify.js +31 -7
  965. package/dist/src/utils/safeJsonStringify.js.map +1 -1
  966. package/dist/src/utils/schemaValidator.js +15 -1
  967. package/dist/src/utils/schemaValidator.js.map +1 -1
  968. package/dist/src/utils/schemaValidator.test.d.ts +6 -0
  969. package/dist/src/utils/schemaValidator.test.js +113 -0
  970. package/dist/src/utils/schemaValidator.test.js.map +1 -0
  971. package/dist/src/utils/session.js +1 -1
  972. package/dist/src/utils/session.js.map +1 -1
  973. package/dist/src/utils/shell-utils.d.ts +21 -3
  974. package/dist/src/utils/shell-utils.js +427 -159
  975. package/dist/src/utils/shell-utils.js.map +1 -1
  976. package/dist/src/utils/shell-utils.test.js +250 -59
  977. package/dist/src/utils/shell-utils.test.js.map +1 -1
  978. package/dist/src/utils/stdio.d.ts +32 -0
  979. package/dist/src/utils/stdio.js +85 -0
  980. package/dist/src/utils/stdio.js.map +1 -0
  981. package/dist/src/utils/stdio.test.d.ts +6 -0
  982. package/dist/src/utils/stdio.test.js +47 -0
  983. package/dist/src/utils/stdio.test.js.map +1 -0
  984. package/dist/src/utils/summarizer.d.ts +6 -4
  985. package/dist/src/utils/summarizer.js +8 -9
  986. package/dist/src/utils/summarizer.js.map +1 -1
  987. package/dist/src/utils/summarizer.test.js +32 -12
  988. package/dist/src/utils/summarizer.test.js.map +1 -1
  989. package/dist/src/utils/systemEncoding.js +7 -6
  990. package/dist/src/utils/systemEncoding.js.map +1 -1
  991. package/dist/src/utils/systemEncoding.test.js +4 -3
  992. package/dist/src/utils/systemEncoding.test.js.map +1 -1
  993. package/dist/src/utils/terminal.d.ts +14 -0
  994. package/dist/src/utils/terminal.js +38 -0
  995. package/dist/src/utils/terminal.js.map +1 -0
  996. package/dist/src/utils/terminalSerializer.d.ts +25 -0
  997. package/dist/src/utils/terminalSerializer.js +432 -0
  998. package/dist/src/utils/terminalSerializer.js.map +1 -0
  999. package/dist/src/utils/terminalSerializer.test.d.ts +6 -0
  1000. package/dist/src/utils/terminalSerializer.test.js +176 -0
  1001. package/dist/src/utils/terminalSerializer.test.js.map +1 -0
  1002. package/dist/src/utils/textUtils.d.ts +5 -0
  1003. package/dist/src/utils/textUtils.js +14 -0
  1004. package/dist/src/utils/textUtils.js.map +1 -1
  1005. package/dist/src/utils/textUtils.test.d.ts +6 -0
  1006. package/dist/src/utils/textUtils.test.js +59 -0
  1007. package/dist/src/utils/textUtils.test.js.map +1 -0
  1008. package/dist/src/utils/thoughtUtils.d.ts +21 -0
  1009. package/dist/src/utils/thoughtUtils.js +39 -0
  1010. package/dist/src/utils/thoughtUtils.js.map +1 -0
  1011. package/dist/src/utils/thoughtUtils.test.d.ts +6 -0
  1012. package/dist/src/utils/thoughtUtils.test.js +78 -0
  1013. package/dist/src/utils/thoughtUtils.test.js.map +1 -0
  1014. package/dist/src/utils/tool-utils.d.ts +19 -0
  1015. package/dist/src/utils/tool-utils.js +67 -0
  1016. package/dist/src/utils/tool-utils.js.map +1 -0
  1017. package/dist/src/utils/tool-utils.test.d.ts +6 -0
  1018. package/dist/src/utils/tool-utils.test.js +69 -0
  1019. package/dist/src/utils/tool-utils.test.js.map +1 -0
  1020. package/dist/src/utils/userAccountManager.d.ts +20 -0
  1021. package/dist/src/utils/userAccountManager.js +115 -0
  1022. package/dist/src/utils/userAccountManager.js.map +1 -0
  1023. package/dist/src/utils/userAccountManager.test.d.ts +6 -0
  1024. package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +41 -36
  1025. package/dist/src/utils/userAccountManager.test.js.map +1 -0
  1026. package/dist/src/utils/workspaceContext.d.ts +4 -3
  1027. package/dist/src/utils/workspaceContext.js +23 -17
  1028. package/dist/src/utils/workspaceContext.js.map +1 -1
  1029. package/dist/src/utils/workspaceContext.test.js +45 -19
  1030. package/dist/src/utils/workspaceContext.test.js.map +1 -1
  1031. package/dist/tsconfig.tsbuildinfo +1 -1
  1032. package/package.json +24 -10
  1033. package/dist/src/core/modelCheck.d.ts +0 -14
  1034. package/dist/src/core/modelCheck.js +0 -62
  1035. package/dist/src/core/modelCheck.js.map +0 -1
  1036. package/dist/src/test-utils/tools.d.ts +0 -44
  1037. package/dist/src/test-utils/tools.js.map +0 -1
  1038. package/dist/src/utils/flashFallback.integration.test.js +0 -118
  1039. package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
  1040. package/dist/src/utils/user_account.d.ts +0 -9
  1041. package/dist/src/utils/user_account.js +0 -109
  1042. package/dist/src/utils/user_account.js.map +0 -1
  1043. package/dist/src/utils/user_account.test.js.map +0 -1
  1044. package/dist/src/utils/user_id.d.ts +0 -11
  1045. package/dist/src/utils/user_id.js +0 -49
  1046. package/dist/src/utils/user_id.js.map +0 -1
  1047. package/dist/src/utils/user_id.test.js +0 -21
  1048. package/dist/src/utils/user_id.test.js.map +0 -1
  1049. /package/dist/src/{utils/flashFallback.integration.test.d.ts → agents/codebase-investigator.test.d.ts} +0 -0
  1050. /package/dist/src/{utils/user_account.test.d.ts → agents/executor.test.d.ts} +0 -0
  1051. /package/dist/src/{utils/user_id.test.d.ts → agents/invocation.test.d.ts} +0 -0
@@ -0,0 +1,717 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import * as fs from 'node:fs';
7
+ import * as path from 'node:path';
8
+ import * as crypto from 'node:crypto';
9
+ import * as Diff from 'diff';
10
+ import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, } from './tools.js';
11
+ import { ToolErrorType } from './tool-error.js';
12
+ import { makeRelative, shortenPath } from '../utils/paths.js';
13
+ import { isNodeError } from '../utils/errors.js';
14
+ import { ApprovalMode } from '../policy/types.js';
15
+ import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
16
+ import {} from './modifiable-tool.js';
17
+ import { IdeClient } from '../ide/ide-client.js';
18
+ import { FixLLMEditWithInstruction } from '../utils/llm-edit-fixer.js';
19
+ import { applyReplacement } from './edit.js';
20
+ import { safeLiteralReplace } from '../utils/textUtils.js';
21
+ import { SmartEditStrategyEvent } from '../telemetry/types.js';
22
+ import { logSmartEditStrategy } from '../telemetry/loggers.js';
23
+ import { SmartEditCorrectionEvent } from '../telemetry/types.js';
24
+ import { logSmartEditCorrectionEvent } from '../telemetry/loggers.js';
25
+ import { correctPath } from '../utils/pathCorrector.js';
26
+ import { EDIT_TOOL_NAME, READ_FILE_TOOL_NAME } from './tool-names.js';
27
+ import { debugLogger } from '../utils/debugLogger.js';
28
+ /**
29
+ * Creates a SHA256 hash of the given content.
30
+ * @param content The string content to hash.
31
+ * @returns A hex-encoded hash string.
32
+ */
33
+ function hashContent(content) {
34
+ return crypto.createHash('sha256').update(content).digest('hex');
35
+ }
36
+ function restoreTrailingNewline(originalContent, modifiedContent) {
37
+ const hadTrailingNewline = originalContent.endsWith('\n');
38
+ if (hadTrailingNewline && !modifiedContent.endsWith('\n')) {
39
+ return modifiedContent + '\n';
40
+ }
41
+ else if (!hadTrailingNewline && modifiedContent.endsWith('\n')) {
42
+ return modifiedContent.replace(/\n$/, '');
43
+ }
44
+ return modifiedContent;
45
+ }
46
+ /**
47
+ * Escapes characters with special meaning in regular expressions.
48
+ * @param str The string to escape.
49
+ * @returns The escaped string.
50
+ */
51
+ function escapeRegex(str) {
52
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
53
+ }
54
+ async function calculateExactReplacement(context) {
55
+ const { currentContent, params } = context;
56
+ const { old_string, new_string } = params;
57
+ const normalizedCode = currentContent;
58
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
59
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
60
+ const exactOccurrences = normalizedCode.split(normalizedSearch).length - 1;
61
+ if (exactOccurrences > 0) {
62
+ let modifiedCode = safeLiteralReplace(normalizedCode, normalizedSearch, normalizedReplace);
63
+ modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
64
+ return {
65
+ newContent: modifiedCode,
66
+ occurrences: exactOccurrences,
67
+ finalOldString: normalizedSearch,
68
+ finalNewString: normalizedReplace,
69
+ };
70
+ }
71
+ return null;
72
+ }
73
+ async function calculateFlexibleReplacement(context) {
74
+ const { currentContent, params } = context;
75
+ const { old_string, new_string } = params;
76
+ const normalizedCode = currentContent;
77
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
78
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
79
+ const sourceLines = normalizedCode.match(/.*(?:\n|$)/g)?.slice(0, -1) ?? [];
80
+ const searchLinesStripped = normalizedSearch
81
+ .split('\n')
82
+ .map((line) => line.trim());
83
+ const replaceLines = normalizedReplace.split('\n');
84
+ let flexibleOccurrences = 0;
85
+ let i = 0;
86
+ while (i <= sourceLines.length - searchLinesStripped.length) {
87
+ const window = sourceLines.slice(i, i + searchLinesStripped.length);
88
+ const windowStripped = window.map((line) => line.trim());
89
+ const isMatch = windowStripped.every((line, index) => line === searchLinesStripped[index]);
90
+ if (isMatch) {
91
+ flexibleOccurrences++;
92
+ const firstLineInMatch = window[0];
93
+ const indentationMatch = firstLineInMatch.match(/^(\s*)/);
94
+ const indentation = indentationMatch ? indentationMatch[1] : '';
95
+ const newBlockWithIndent = replaceLines.map((line) => `${indentation}${line}`);
96
+ sourceLines.splice(i, searchLinesStripped.length, newBlockWithIndent.join('\n'));
97
+ i += replaceLines.length;
98
+ }
99
+ else {
100
+ i++;
101
+ }
102
+ }
103
+ if (flexibleOccurrences > 0) {
104
+ let modifiedCode = sourceLines.join('');
105
+ modifiedCode = restoreTrailingNewline(currentContent, modifiedCode);
106
+ return {
107
+ newContent: modifiedCode,
108
+ occurrences: flexibleOccurrences,
109
+ finalOldString: normalizedSearch,
110
+ finalNewString: normalizedReplace,
111
+ };
112
+ }
113
+ return null;
114
+ }
115
+ async function calculateRegexReplacement(context) {
116
+ const { currentContent, params } = context;
117
+ const { old_string, new_string } = params;
118
+ // Normalize line endings for consistent processing.
119
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
120
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
121
+ // This logic is ported from your Python implementation.
122
+ // It builds a flexible, multi-line regex from a search string.
123
+ const delimiters = ['(', ')', ':', '[', ']', '{', '}', '>', '<', '='];
124
+ let processedString = normalizedSearch;
125
+ for (const delim of delimiters) {
126
+ processedString = processedString.split(delim).join(` ${delim} `);
127
+ }
128
+ // Split by any whitespace and remove empty strings.
129
+ const tokens = processedString.split(/\s+/).filter(Boolean);
130
+ if (tokens.length === 0) {
131
+ return null;
132
+ }
133
+ const escapedTokens = tokens.map(escapeRegex);
134
+ // Join tokens with `\s*` to allow for flexible whitespace between them.
135
+ const pattern = escapedTokens.join('\\s*');
136
+ // The final pattern captures leading whitespace (indentation) and then matches the token pattern.
137
+ // 'm' flag enables multi-line mode, so '^' matches the start of any line.
138
+ const finalPattern = `^(\\s*)${pattern}`;
139
+ const flexibleRegex = new RegExp(finalPattern, 'm');
140
+ const match = flexibleRegex.exec(currentContent);
141
+ if (!match) {
142
+ return null;
143
+ }
144
+ const indentation = match[1] || '';
145
+ const newLines = normalizedReplace.split('\n');
146
+ const newBlockWithIndent = newLines
147
+ .map((line) => `${indentation}${line}`)
148
+ .join('\n');
149
+ // Use replace with the regex to substitute the matched content.
150
+ // Since the regex doesn't have the 'g' flag, it will only replace the first occurrence.
151
+ const modifiedCode = currentContent.replace(flexibleRegex, newBlockWithIndent);
152
+ return {
153
+ newContent: restoreTrailingNewline(currentContent, modifiedCode),
154
+ occurrences: 1, // This method is designed to find and replace only the first occurrence.
155
+ finalOldString: normalizedSearch,
156
+ finalNewString: normalizedReplace,
157
+ };
158
+ }
159
+ /**
160
+ * Detects the line ending style of a string.
161
+ * @param content The string content to analyze.
162
+ * @returns '\r\n' for Windows-style, '\n' for Unix-style.
163
+ */
164
+ function detectLineEnding(content) {
165
+ // If a Carriage Return is found, assume Windows-style endings.
166
+ // This is a simple but effective heuristic.
167
+ return content.includes('\r\n') ? '\r\n' : '\n';
168
+ }
169
+ export async function calculateReplacement(config, context) {
170
+ const { currentContent, params } = context;
171
+ const { old_string, new_string } = params;
172
+ const normalizedSearch = old_string.replace(/\r\n/g, '\n');
173
+ const normalizedReplace = new_string.replace(/\r\n/g, '\n');
174
+ if (normalizedSearch === '') {
175
+ return {
176
+ newContent: currentContent,
177
+ occurrences: 0,
178
+ finalOldString: normalizedSearch,
179
+ finalNewString: normalizedReplace,
180
+ };
181
+ }
182
+ const exactResult = await calculateExactReplacement(context);
183
+ if (exactResult) {
184
+ const event = new SmartEditStrategyEvent('exact');
185
+ logSmartEditStrategy(config, event);
186
+ return exactResult;
187
+ }
188
+ const flexibleResult = await calculateFlexibleReplacement(context);
189
+ if (flexibleResult) {
190
+ const event = new SmartEditStrategyEvent('flexible');
191
+ logSmartEditStrategy(config, event);
192
+ return flexibleResult;
193
+ }
194
+ const regexResult = await calculateRegexReplacement(context);
195
+ if (regexResult) {
196
+ const event = new SmartEditStrategyEvent('regex');
197
+ logSmartEditStrategy(config, event);
198
+ return regexResult;
199
+ }
200
+ return {
201
+ newContent: currentContent,
202
+ occurrences: 0,
203
+ finalOldString: normalizedSearch,
204
+ finalNewString: normalizedReplace,
205
+ };
206
+ }
207
+ export function getErrorReplaceResult(params, occurrences, expectedReplacements, finalOldString, finalNewString) {
208
+ let error = undefined;
209
+ if (occurrences === 0) {
210
+ error = {
211
+ display: `Failed to edit, could not find the string to replace.`,
212
+ raw: `Failed to edit, 0 occurrences found for old_string (${finalOldString}). Original old_string was (${params.old_string}) in ${params.file_path}. No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${READ_FILE_TOOL_NAME} tool to verify.`,
213
+ type: ToolErrorType.EDIT_NO_OCCURRENCE_FOUND,
214
+ };
215
+ }
216
+ else if (occurrences !== expectedReplacements) {
217
+ const occurrenceTerm = expectedReplacements === 1 ? 'occurrence' : 'occurrences';
218
+ error = {
219
+ display: `Failed to edit, expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences}.`,
220
+ raw: `Failed to edit, Expected ${expectedReplacements} ${occurrenceTerm} but found ${occurrences} for old_string in file: ${params.file_path}`,
221
+ type: ToolErrorType.EDIT_EXPECTED_OCCURRENCE_MISMATCH,
222
+ };
223
+ }
224
+ else if (finalOldString === finalNewString) {
225
+ error = {
226
+ display: `No changes to apply. The old_string and new_string are identical.`,
227
+ raw: `No changes to apply. The old_string and new_string are identical in file: ${params.file_path}`,
228
+ type: ToolErrorType.EDIT_NO_CHANGE,
229
+ };
230
+ }
231
+ return error;
232
+ }
233
+ class EditToolInvocation extends BaseToolInvocation {
234
+ config;
235
+ constructor(config, params, messageBus, toolName, displayName) {
236
+ super(params, messageBus, toolName, displayName);
237
+ this.config = config;
238
+ }
239
+ toolLocations() {
240
+ return [{ path: this.params.file_path }];
241
+ }
242
+ async attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding) {
243
+ // In order to keep from clobbering edits made outside our system,
244
+ // check if the file has been modified since we first read it.
245
+ let errorForLlmEditFixer = initialError.raw;
246
+ let contentForLlmEditFixer = currentContent;
247
+ const initialContentHash = hashContent(currentContent);
248
+ const onDiskContent = await this.config
249
+ .getFileSystemService()
250
+ .readTextFile(params.file_path);
251
+ const onDiskContentHash = hashContent(onDiskContent.replace(/\r\n/g, '\n'));
252
+ if (initialContentHash !== onDiskContentHash) {
253
+ // The file has changed on disk since we first read it.
254
+ // Use the latest content for the correction attempt.
255
+ contentForLlmEditFixer = onDiskContent.replace(/\r\n/g, '\n');
256
+ errorForLlmEditFixer = `The initial edit attempt failed with the following error: "${initialError.raw}". However, the file has been modified by either the user or an external process since that edit attempt. The file content provided to you is the latest version. Please base your correction on this new content.`;
257
+ }
258
+ const fixedEdit = await FixLLMEditWithInstruction(params.instruction, params.old_string, params.new_string, errorForLlmEditFixer, contentForLlmEditFixer, this.config.getBaseLlmClient(), abortSignal);
259
+ // If the self-correction attempt timed out, return the original error.
260
+ if (fixedEdit === null) {
261
+ return {
262
+ currentContent: contentForLlmEditFixer,
263
+ newContent: currentContent,
264
+ occurrences: 0,
265
+ isNewFile: false,
266
+ error: initialError,
267
+ originalLineEnding,
268
+ };
269
+ }
270
+ if (fixedEdit.noChangesRequired) {
271
+ return {
272
+ currentContent,
273
+ newContent: currentContent,
274
+ occurrences: 0,
275
+ isNewFile: false,
276
+ error: {
277
+ display: `No changes required. The file already meets the specified conditions.`,
278
+ raw: `A secondary check by an LLM determined that no changes were necessary to fulfill the instruction. Explanation: ${fixedEdit.explanation}. Original error with the parameters given: ${initialError.raw}`,
279
+ type: ToolErrorType.EDIT_NO_CHANGE_LLM_JUDGEMENT,
280
+ },
281
+ originalLineEnding,
282
+ };
283
+ }
284
+ const secondAttemptResult = await calculateReplacement(this.config, {
285
+ params: {
286
+ ...params,
287
+ old_string: fixedEdit.search,
288
+ new_string: fixedEdit.replace,
289
+ },
290
+ currentContent: contentForLlmEditFixer,
291
+ abortSignal,
292
+ });
293
+ const secondError = getErrorReplaceResult(params, secondAttemptResult.occurrences, params.expected_replacements ?? 1, secondAttemptResult.finalOldString, secondAttemptResult.finalNewString);
294
+ if (secondError) {
295
+ // The fix failed, log failure and return the original error
296
+ const event = new SmartEditCorrectionEvent('failure');
297
+ logSmartEditCorrectionEvent(this.config, event);
298
+ return {
299
+ currentContent: contentForLlmEditFixer,
300
+ newContent: currentContent,
301
+ occurrences: 0,
302
+ isNewFile: false,
303
+ error: initialError,
304
+ originalLineEnding,
305
+ };
306
+ }
307
+ const event = new SmartEditCorrectionEvent('success');
308
+ logSmartEditCorrectionEvent(this.config, event);
309
+ return {
310
+ currentContent: contentForLlmEditFixer,
311
+ newContent: secondAttemptResult.newContent,
312
+ occurrences: secondAttemptResult.occurrences,
313
+ isNewFile: false,
314
+ error: undefined,
315
+ originalLineEnding,
316
+ };
317
+ }
318
+ /**
319
+ * Calculates the potential outcome of an edit operation.
320
+ * @param params Parameters for the edit operation
321
+ * @returns An object describing the potential edit outcome
322
+ * @throws File system errors if reading the file fails unexpectedly (e.g., permissions)
323
+ */
324
+ async calculateEdit(params, abortSignal) {
325
+ const expectedReplacements = params.expected_replacements ?? 1;
326
+ let currentContent = null;
327
+ let fileExists = false;
328
+ let originalLineEnding = '\n'; // Default for new files
329
+ try {
330
+ currentContent = await this.config
331
+ .getFileSystemService()
332
+ .readTextFile(params.file_path);
333
+ originalLineEnding = detectLineEnding(currentContent);
334
+ currentContent = currentContent.replace(/\r\n/g, '\n');
335
+ fileExists = true;
336
+ }
337
+ catch (err) {
338
+ if (!isNodeError(err) || err.code !== 'ENOENT') {
339
+ throw err;
340
+ }
341
+ fileExists = false;
342
+ }
343
+ const isNewFile = params.old_string === '' && !fileExists;
344
+ if (isNewFile) {
345
+ return {
346
+ currentContent,
347
+ newContent: params.new_string,
348
+ occurrences: 1,
349
+ isNewFile: true,
350
+ error: undefined,
351
+ originalLineEnding,
352
+ };
353
+ }
354
+ // after this point, it's not a new file/edit
355
+ if (!fileExists) {
356
+ return {
357
+ currentContent,
358
+ newContent: '',
359
+ occurrences: 0,
360
+ isNewFile: false,
361
+ error: {
362
+ display: `File not found. Cannot apply edit. Use an empty old_string to create a new file.`,
363
+ raw: `File not found: ${params.file_path}`,
364
+ type: ToolErrorType.FILE_NOT_FOUND,
365
+ },
366
+ originalLineEnding,
367
+ };
368
+ }
369
+ if (currentContent === null) {
370
+ return {
371
+ currentContent,
372
+ newContent: '',
373
+ occurrences: 0,
374
+ isNewFile: false,
375
+ error: {
376
+ display: `Failed to read content of file.`,
377
+ raw: `Failed to read content of existing file: ${params.file_path}`,
378
+ type: ToolErrorType.READ_CONTENT_FAILURE,
379
+ },
380
+ originalLineEnding,
381
+ };
382
+ }
383
+ if (params.old_string === '') {
384
+ return {
385
+ currentContent,
386
+ newContent: currentContent,
387
+ occurrences: 0,
388
+ isNewFile: false,
389
+ error: {
390
+ display: `Failed to edit. Attempted to create a file that already exists.`,
391
+ raw: `File already exists, cannot create: ${params.file_path}`,
392
+ type: ToolErrorType.ATTEMPT_TO_CREATE_EXISTING_FILE,
393
+ },
394
+ originalLineEnding,
395
+ };
396
+ }
397
+ const replacementResult = await calculateReplacement(this.config, {
398
+ params,
399
+ currentContent,
400
+ abortSignal,
401
+ });
402
+ const initialError = getErrorReplaceResult(params, replacementResult.occurrences, expectedReplacements, replacementResult.finalOldString, replacementResult.finalNewString);
403
+ if (!initialError) {
404
+ return {
405
+ currentContent,
406
+ newContent: replacementResult.newContent,
407
+ occurrences: replacementResult.occurrences,
408
+ isNewFile: false,
409
+ error: undefined,
410
+ originalLineEnding,
411
+ };
412
+ }
413
+ // If there was an error, try to self-correct.
414
+ return this.attemptSelfCorrection(params, currentContent, initialError, abortSignal, originalLineEnding);
415
+ }
416
+ /**
417
+ * Handles the confirmation prompt for the Edit tool in the CLI.
418
+ * It needs to calculate the diff to show the user.
419
+ */
420
+ async getConfirmationDetails(abortSignal) {
421
+ if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
422
+ return false;
423
+ }
424
+ let editData;
425
+ try {
426
+ editData = await this.calculateEdit(this.params, abortSignal);
427
+ }
428
+ catch (error) {
429
+ if (abortSignal.aborted) {
430
+ throw error;
431
+ }
432
+ const errorMsg = error instanceof Error ? error.message : String(error);
433
+ debugLogger.log(`Error preparing edit: ${errorMsg}`);
434
+ return false;
435
+ }
436
+ if (editData.error) {
437
+ debugLogger.log(`Error: ${editData.error.display}`);
438
+ return false;
439
+ }
440
+ const fileName = path.basename(this.params.file_path);
441
+ const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
442
+ const ideClient = await IdeClient.getInstance();
443
+ const ideConfirmation = this.config.getIdeMode() && ideClient.isDiffingEnabled()
444
+ ? ideClient.openDiff(this.params.file_path, editData.newContent)
445
+ : undefined;
446
+ const confirmationDetails = {
447
+ type: 'edit',
448
+ title: `Confirm Edit: ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`,
449
+ fileName,
450
+ filePath: this.params.file_path,
451
+ fileDiff,
452
+ originalContent: editData.currentContent,
453
+ newContent: editData.newContent,
454
+ onConfirm: async (outcome) => {
455
+ if (outcome === ToolConfirmationOutcome.ProceedAlways) {
456
+ this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
457
+ }
458
+ if (ideConfirmation) {
459
+ const result = await ideConfirmation;
460
+ if (result.status === 'accepted' && result.content) {
461
+ // TODO(chrstn): See https://github.com/google-gemini/gemini-cli/pull/5618#discussion_r2255413084
462
+ // for info on a possible race condition where the file is modified on disk while being edited.
463
+ this.params.old_string = editData.currentContent ?? '';
464
+ this.params.new_string = result.content;
465
+ }
466
+ }
467
+ },
468
+ ideConfirmation,
469
+ };
470
+ return confirmationDetails;
471
+ }
472
+ getDescription() {
473
+ const relativePath = makeRelative(this.params.file_path, this.config.getTargetDir());
474
+ if (this.params.old_string === '') {
475
+ return `Create ${shortenPath(relativePath)}`;
476
+ }
477
+ const oldStringSnippet = this.params.old_string.split('\n')[0].substring(0, 30) +
478
+ (this.params.old_string.length > 30 ? '...' : '');
479
+ const newStringSnippet = this.params.new_string.split('\n')[0].substring(0, 30) +
480
+ (this.params.new_string.length > 30 ? '...' : '');
481
+ if (this.params.old_string === this.params.new_string) {
482
+ return `No file changes to ${shortenPath(relativePath)}`;
483
+ }
484
+ return `${shortenPath(relativePath)}: ${oldStringSnippet} => ${newStringSnippet}`;
485
+ }
486
+ /**
487
+ * Executes the edit operation with the given parameters.
488
+ * @param params Parameters for the edit operation
489
+ * @returns Result of the edit operation
490
+ */
491
+ async execute(signal) {
492
+ let editData;
493
+ try {
494
+ editData = await this.calculateEdit(this.params, signal);
495
+ }
496
+ catch (error) {
497
+ if (signal.aborted) {
498
+ throw error;
499
+ }
500
+ const errorMsg = error instanceof Error ? error.message : String(error);
501
+ return {
502
+ llmContent: `Error preparing edit: ${errorMsg}`,
503
+ returnDisplay: `Error preparing edit: ${errorMsg}`,
504
+ error: {
505
+ message: errorMsg,
506
+ type: ToolErrorType.EDIT_PREPARATION_FAILURE,
507
+ },
508
+ };
509
+ }
510
+ if (editData.error) {
511
+ return {
512
+ llmContent: editData.error.raw,
513
+ returnDisplay: `Error: ${editData.error.display}`,
514
+ error: {
515
+ message: editData.error.raw,
516
+ type: editData.error.type,
517
+ },
518
+ };
519
+ }
520
+ try {
521
+ this.ensureParentDirectoriesExist(this.params.file_path);
522
+ let finalContent = editData.newContent;
523
+ // Restore original line endings if they were CRLF
524
+ if (!editData.isNewFile && editData.originalLineEnding === '\r\n') {
525
+ finalContent = finalContent.replace(/\n/g, '\r\n');
526
+ }
527
+ await this.config
528
+ .getFileSystemService()
529
+ .writeTextFile(this.params.file_path, finalContent);
530
+ let displayResult;
531
+ if (editData.isNewFile) {
532
+ displayResult = `Created ${shortenPath(makeRelative(this.params.file_path, this.config.getTargetDir()))}`;
533
+ }
534
+ else {
535
+ // Generate diff for display, even though core logic doesn't technically need it
536
+ // The CLI wrapper will use this part of the ToolResult
537
+ const fileName = path.basename(this.params.file_path);
538
+ const fileDiff = Diff.createPatch(fileName, editData.currentContent ?? '', // Should not be null here if not isNewFile
539
+ editData.newContent, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
540
+ const diffStat = getDiffStat(fileName, editData.currentContent ?? '', editData.newContent, this.params.new_string);
541
+ displayResult = {
542
+ fileDiff,
543
+ fileName,
544
+ originalContent: editData.currentContent,
545
+ newContent: editData.newContent,
546
+ diffStat,
547
+ };
548
+ }
549
+ const llmSuccessMessageParts = [
550
+ editData.isNewFile
551
+ ? `Created new file: ${this.params.file_path} with provided content.`
552
+ : `Successfully modified file: ${this.params.file_path} (${editData.occurrences} replacements).`,
553
+ ];
554
+ if (this.params.modified_by_user) {
555
+ llmSuccessMessageParts.push(`User modified the \`new_string\` content to be: ${this.params.new_string}.`);
556
+ }
557
+ return {
558
+ llmContent: llmSuccessMessageParts.join(' '),
559
+ returnDisplay: displayResult,
560
+ };
561
+ }
562
+ catch (error) {
563
+ const errorMsg = error instanceof Error ? error.message : String(error);
564
+ return {
565
+ llmContent: `Error executing edit: ${errorMsg}`,
566
+ returnDisplay: `Error writing file: ${errorMsg}`,
567
+ error: {
568
+ message: errorMsg,
569
+ type: ToolErrorType.FILE_WRITE_FAILURE,
570
+ },
571
+ };
572
+ }
573
+ }
574
+ /**
575
+ * Creates parent directories if they don't exist
576
+ */
577
+ ensureParentDirectoriesExist(filePath) {
578
+ const dirName = path.dirname(filePath);
579
+ if (!fs.existsSync(dirName)) {
580
+ fs.mkdirSync(dirName, { recursive: true });
581
+ }
582
+ }
583
+ }
584
+ /**
585
+ * Implementation of the Edit tool logic
586
+ */
587
+ export class SmartEditTool extends BaseDeclarativeTool {
588
+ config;
589
+ static Name = EDIT_TOOL_NAME;
590
+ constructor(config, messageBus) {
591
+ super(SmartEditTool.Name, 'Edit', `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.
592
+
593
+ The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
594
+
595
+ Expectation for required parameters:
596
+ 1. \`old_string\` MUST be the exact literal text to replace (including all whitespace, indentation, newlines, and surrounding code etc.).
597
+ 2. \`new_string\` MUST be the exact literal text to replace \`old_string\` with (also including all whitespace, indentation, newlines, and surrounding code etc.). Ensure the resulting code is correct and idiomatic and that \`old_string\` and \`new_string\` are different.
598
+ 3. \`instruction\` is the detailed instruction of what needs to be changed. It is important to Make it specific and detailed so developers or large language models can understand what needs to be changed and perform the changes on their own if necessary.
599
+ 4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
600
+ **Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.
601
+ 5. Prefer to break down complex and long changes into multiple smaller atomic calls to this tool. Always check the content of the file after changes or not finding a string to match.
602
+ **Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.`, Kind.Edit, {
603
+ properties: {
604
+ file_path: {
605
+ description: 'The path to the file to modify.',
606
+ type: 'string',
607
+ },
608
+ instruction: {
609
+ description: `A clear, semantic instruction for the code change, acting as a high-quality prompt for an expert LLM assistant. It must be self-contained and explain the goal of the change.
610
+
611
+ A good instruction should concisely answer:
612
+ 1. WHY is the change needed? (e.g., "To fix a bug where users can be null...")
613
+ 2. WHERE should the change happen? (e.g., "...in the 'renderUserProfile' function...")
614
+ 3. WHAT is the high-level change? (e.g., "...add a null check for the 'user' object...")
615
+ 4. WHAT is the desired outcome? (e.g., "...so that it displays a loading spinner instead of crashing.")
616
+
617
+ **GOOD Example:** "In the 'calculateTotal' function, correct the sales tax calculation by updating the 'taxRate' constant from 0.05 to 0.075 to reflect the new regional tax laws."
618
+
619
+ **BAD Examples:**
620
+ - "Change the text." (Too vague)
621
+ - "Fix the bug." (Doesn't explain the bug or the fix)
622
+ - "Replace the line with this new line." (Brittle, just repeats the other parameters)
623
+ `,
624
+ type: 'string',
625
+ },
626
+ old_string: {
627
+ description: 'The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail.',
628
+ type: 'string',
629
+ },
630
+ new_string: {
631
+ description: 'The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic.',
632
+ type: 'string',
633
+ },
634
+ expected_replacements: {
635
+ type: 'number',
636
+ description: 'Number of replacements expected. Defaults to 1 if not specified. Use when you want to replace multiple occurrences.',
637
+ minimum: 1,
638
+ },
639
+ },
640
+ required: ['file_path', 'instruction', 'old_string', 'new_string'],
641
+ type: 'object',
642
+ }, true, // isOutputMarkdown
643
+ false, // canUpdateOutput
644
+ messageBus);
645
+ this.config = config;
646
+ }
647
+ /**
648
+ * Validates the parameters for the Edit tool
649
+ * @param params Parameters to validate
650
+ * @returns Error message string or null if valid
651
+ */
652
+ validateToolParamValues(params) {
653
+ if (!params.file_path) {
654
+ return "The 'file_path' parameter must be non-empty.";
655
+ }
656
+ let filePath = params.file_path;
657
+ if (!path.isAbsolute(filePath)) {
658
+ // Attempt to auto-correct to an absolute path
659
+ const result = correctPath(filePath, this.config);
660
+ if (!result.success) {
661
+ return result.error;
662
+ }
663
+ filePath = result.correctedPath;
664
+ }
665
+ params.file_path = filePath;
666
+ const workspaceContext = this.config.getWorkspaceContext();
667
+ if (!workspaceContext.isPathWithinWorkspace(params.file_path)) {
668
+ const directories = workspaceContext.getDirectories();
669
+ return `File path must be within one of the workspace directories: ${directories.join(', ')}`;
670
+ }
671
+ return null;
672
+ }
673
+ createInvocation(params) {
674
+ return new EditToolInvocation(this.config, params, this.messageBus, this.name, this.displayName);
675
+ }
676
+ getModifyContext(_) {
677
+ return {
678
+ getFilePath: (params) => params.file_path,
679
+ getCurrentContent: async (params) => {
680
+ try {
681
+ return this.config
682
+ .getFileSystemService()
683
+ .readTextFile(params.file_path);
684
+ }
685
+ catch (err) {
686
+ if (!isNodeError(err) || err.code !== 'ENOENT')
687
+ throw err;
688
+ return '';
689
+ }
690
+ },
691
+ getProposedContent: async (params) => {
692
+ try {
693
+ const currentContent = await this.config
694
+ .getFileSystemService()
695
+ .readTextFile(params.file_path);
696
+ return applyReplacement(currentContent, params.old_string, params.new_string, params.old_string === '' && currentContent === '');
697
+ }
698
+ catch (err) {
699
+ if (!isNodeError(err) || err.code !== 'ENOENT')
700
+ throw err;
701
+ return '';
702
+ }
703
+ },
704
+ createUpdatedParams: (oldContent, modifiedProposedContent, originalParams) => {
705
+ const content = originalParams.new_string;
706
+ return {
707
+ ...originalParams,
708
+ ai_proposed_string: content,
709
+ old_string: oldContent,
710
+ new_string: modifiedProposedContent,
711
+ modified_by_user: true,
712
+ };
713
+ },
714
+ };
715
+ }
716
+ }
717
+ //# sourceMappingURL=smart-edit.js.map