@machina.ai/cell-cli-core 1.0.21-rc4 → 1.4.0-rc1

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 (505) hide show
  1. package/dist/index.d.ts +6 -2
  2. package/dist/index.js +6 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +25 -11
  5. package/dist/src/code_assist/codeAssist.d.ts +6 -3
  6. package/dist/src/code_assist/codeAssist.js +12 -0
  7. package/dist/src/code_assist/codeAssist.js.map +1 -1
  8. package/dist/src/code_assist/converter.d.ts +3 -1
  9. package/dist/src/code_assist/converter.js +37 -5
  10. package/dist/src/code_assist/converter.js.map +1 -1
  11. package/dist/src/code_assist/converter.test.js +83 -0
  12. package/dist/src/code_assist/converter.test.js.map +1 -1
  13. package/dist/src/code_assist/oauth2.d.ts +2 -1
  14. package/dist/src/code_assist/oauth2.js +85 -49
  15. package/dist/src/code_assist/oauth2.js.map +1 -1
  16. package/dist/src/code_assist/oauth2.test.js +317 -15
  17. package/dist/src/code_assist/oauth2.test.js.map +1 -1
  18. package/dist/src/code_assist/server.d.ts +5 -5
  19. package/dist/src/code_assist/server.js +1 -1
  20. package/dist/src/code_assist/server.js.map +1 -1
  21. package/dist/src/code_assist/setup.d.ts +1 -1
  22. package/dist/src/code_assist/setup.js +1 -1
  23. package/dist/src/code_assist/setup.js.map +1 -1
  24. package/dist/src/code_assist/setup.test.js.map +1 -1
  25. package/dist/src/config/config.d.ts +53 -15
  26. package/dist/src/config/config.js +127 -47
  27. package/dist/src/config/config.js.map +1 -1
  28. package/dist/src/config/config.test.js +151 -6
  29. package/dist/src/config/config.test.js.map +1 -1
  30. package/dist/src/config/models.d.ts +1 -0
  31. package/dist/src/config/models.js +2 -0
  32. package/dist/src/config/models.js.map +1 -1
  33. package/dist/src/config/storage.d.ts +32 -0
  34. package/dist/src/config/storage.js +90 -0
  35. package/dist/src/config/storage.js.map +1 -0
  36. package/dist/src/config/storage.test.js +43 -0
  37. package/dist/src/config/storage.test.js.map +1 -0
  38. package/dist/src/core/client.d.ts +21 -11
  39. package/dist/src/core/client.js +83 -26
  40. package/dist/src/core/client.js.map +1 -1
  41. package/dist/src/core/client.test.js +398 -88
  42. package/dist/src/core/client.test.js.map +1 -1
  43. package/dist/src/core/contentGenerator.d.ts +6 -6
  44. package/dist/src/core/contentGenerator.js +4 -3
  45. package/dist/src/core/contentGenerator.js.map +1 -1
  46. package/dist/src/core/contentGenerator.test.js.map +1 -1
  47. package/dist/src/core/coreToolScheduler.d.ts +14 -5
  48. package/dist/src/core/coreToolScheduler.js +120 -49
  49. package/dist/src/core/coreToolScheduler.js.map +1 -1
  50. package/dist/src/core/coreToolScheduler.test.js +383 -72
  51. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  52. package/dist/src/core/geminiChat.d.ts +48 -15
  53. package/dist/src/core/geminiChat.js +327 -154
  54. package/dist/src/core/geminiChat.js.map +1 -1
  55. package/dist/src/core/geminiChat.test.js +1041 -257
  56. package/dist/src/core/geminiChat.test.js.map +1 -1
  57. package/dist/src/core/geminiRequest.js +1 -0
  58. package/dist/src/core/geminiRequest.js.map +1 -1
  59. package/dist/src/core/logger.d.ts +4 -2
  60. package/dist/src/core/logger.js +4 -3
  61. package/dist/src/core/logger.js.map +1 -1
  62. package/dist/src/core/logger.test.js +19 -18
  63. package/dist/src/core/logger.test.js.map +1 -1
  64. package/dist/src/core/loggingContentGenerator.d.ts +3 -3
  65. package/dist/src/core/loggingContentGenerator.js +11 -9
  66. package/dist/src/core/loggingContentGenerator.js.map +1 -1
  67. package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -5
  68. package/dist/src/core/nonInteractiveToolExecutor.js +15 -123
  69. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  70. package/dist/src/core/nonInteractiveToolExecutor.test.js +116 -90
  71. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  72. package/dist/src/core/prompts.js +8 -7
  73. package/dist/src/core/prompts.js.map +1 -1
  74. package/dist/src/core/prompts.test.js +21 -21
  75. package/dist/src/core/prompts.test.js.map +1 -1
  76. package/dist/src/core/subagent.d.ts +24 -18
  77. package/dist/src/core/subagent.js +126 -89
  78. package/dist/src/core/subagent.js.map +1 -1
  79. package/dist/src/core/subagent.test.js +51 -35
  80. package/dist/src/core/subagent.test.js.map +1 -1
  81. package/dist/src/core/turn.d.ts +33 -8
  82. package/dist/src/core/turn.js +59 -14
  83. package/dist/src/core/turn.js.map +1 -1
  84. package/dist/src/core/turn.test.js +349 -90
  85. package/dist/src/core/turn.test.js.map +1 -1
  86. package/dist/src/generated/git-commit.d.ts +2 -2
  87. package/dist/src/generated/git-commit.js +2 -2
  88. package/dist/src/generated/git-commit.js.map +1 -1
  89. package/dist/src/ide/constants.d.ts +1 -1
  90. package/dist/src/ide/constants.js +1 -1
  91. package/dist/src/ide/constants.js.map +1 -1
  92. package/dist/src/ide/detect-ide.d.ts +8 -3
  93. package/dist/src/ide/detect-ide.js +29 -11
  94. package/dist/src/ide/detect-ide.js.map +1 -1
  95. package/dist/src/ide/detect-ide.test.js +96 -52
  96. package/dist/src/ide/detect-ide.test.js.map +1 -1
  97. package/dist/src/ide/ide-client.d.ts +18 -9
  98. package/dist/src/ide/ide-client.js +151 -33
  99. package/dist/src/ide/ide-client.js.map +1 -1
  100. package/dist/src/ide/ide-client.test.js +147 -25
  101. package/dist/src/ide/ide-client.test.js.map +1 -1
  102. package/dist/src/ide/ide-installer.d.ts +1 -1
  103. package/dist/src/ide/ide-installer.js +31 -22
  104. package/dist/src/ide/ide-installer.js.map +1 -1
  105. package/dist/src/ide/ide-installer.test.js +82 -22
  106. package/dist/src/ide/ide-installer.test.js.map +1 -1
  107. package/dist/src/ide/ideContext.d.ts +12 -0
  108. package/dist/src/ide/ideContext.js +1 -0
  109. package/dist/src/ide/ideContext.js.map +1 -1
  110. package/dist/src/ide/process-utils.d.ts +13 -6
  111. package/dist/src/ide/process-utils.js +142 -35
  112. package/dist/src/ide/process-utils.js.map +1 -1
  113. package/dist/src/ide/process-utils.test.js +158 -0
  114. package/dist/src/ide/process-utils.test.js.map +1 -0
  115. package/dist/src/index.d.ts +12 -2
  116. package/dist/src/index.js +11 -1
  117. package/dist/src/index.js.map +1 -1
  118. package/dist/src/mcp/google-auth-provider.d.ts +3 -3
  119. package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
  120. package/dist/src/mcp/oauth-provider.d.ts +13 -13
  121. package/dist/src/mcp/oauth-provider.js +32 -31
  122. package/dist/src/mcp/oauth-provider.js.map +1 -1
  123. package/dist/src/mcp/oauth-provider.test.js +75 -36
  124. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  125. package/dist/src/mcp/oauth-token-storage.d.ts +9 -31
  126. package/dist/src/mcp/oauth-token-storage.js +10 -13
  127. package/dist/src/mcp/oauth-token-storage.js.map +1 -1
  128. package/dist/src/mcp/oauth-token-storage.test.js +30 -27
  129. package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
  130. package/dist/src/mcp/oauth-utils.d.ts +9 -1
  131. package/dist/src/mcp/oauth-utils.js +41 -27
  132. package/dist/src/mcp/oauth-utils.js.map +1 -1
  133. package/dist/src/mcp/oauth-utils.test.js +41 -1
  134. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  135. package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
  136. package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
  137. package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
  138. package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
  139. package/dist/src/mcp/token-storage/base-token-storage.test.js +160 -0
  140. package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
  141. package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
  142. package/dist/src/mcp/token-storage/file-token-storage.js +144 -0
  143. package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
  144. package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
  145. package/dist/src/mcp/token-storage/file-token-storage.test.js +235 -0
  146. package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
  147. package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
  148. package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
  149. package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
  150. package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
  151. package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
  152. package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
  153. package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +31 -0
  154. package/dist/src/mcp/token-storage/keychain-token-storage.js +190 -0
  155. package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
  156. package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
  157. package/dist/src/mcp/token-storage/keychain-token-storage.test.js +254 -0
  158. package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
  159. package/dist/src/mcp/token-storage/types.d.ts +38 -0
  160. package/dist/src/mcp/token-storage/types.js +11 -0
  161. package/dist/src/mcp/token-storage/types.js.map +1 -0
  162. package/dist/src/prompts/mcp-prompts.d.ts +2 -2
  163. package/dist/src/prompts/prompt-registry.d.ts +1 -1
  164. package/dist/src/services/chatRecordingService.d.ts +6 -13
  165. package/dist/src/services/chatRecordingService.js +31 -19
  166. package/dist/src/services/chatRecordingService.js.map +1 -1
  167. package/dist/src/services/chatRecordingService.test.js +64 -25
  168. package/dist/src/services/chatRecordingService.test.js.map +1 -1
  169. package/dist/src/services/fileDiscoveryService.js +1 -1
  170. package/dist/src/services/fileDiscoveryService.js.map +1 -1
  171. package/dist/src/services/fileDiscoveryService.test.js +3 -3
  172. package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
  173. package/dist/src/services/fileSystemService.js +1 -1
  174. package/dist/src/services/fileSystemService.js.map +1 -1
  175. package/dist/src/services/fileSystemService.test.js +1 -1
  176. package/dist/src/services/fileSystemService.test.js.map +1 -1
  177. package/dist/src/services/gitService.d.ts +3 -1
  178. package/dist/src/services/gitService.js +21 -12
  179. package/dist/src/services/gitService.js.map +1 -1
  180. package/dist/src/services/gitService.test.js +22 -19
  181. package/dist/src/services/gitService.test.js.map +1 -1
  182. package/dist/src/services/loopDetectionService.d.ts +3 -2
  183. package/dist/src/services/loopDetectionService.js +28 -4
  184. package/dist/src/services/loopDetectionService.js.map +1 -1
  185. package/dist/src/services/loopDetectionService.test.js +23 -1
  186. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  187. package/dist/src/services/shellExecutionService.d.ts +8 -10
  188. package/dist/src/services/shellExecutionService.js +292 -135
  189. package/dist/src/services/shellExecutionService.js.map +1 -1
  190. package/dist/src/services/shellExecutionService.test.js +277 -42
  191. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  192. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +18 -4
  193. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +171 -11
  194. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  195. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +103 -11
  196. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  197. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +31 -1
  198. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +75 -0
  199. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  200. package/dist/src/telemetry/constants.d.ts +9 -0
  201. package/dist/src/telemetry/constants.js +9 -0
  202. package/dist/src/telemetry/constants.js.map +1 -1
  203. package/dist/src/telemetry/file-exporters.d.ts +5 -4
  204. package/dist/src/telemetry/file-exporters.js +1 -1
  205. package/dist/src/telemetry/file-exporters.js.map +1 -1
  206. package/dist/src/telemetry/index.d.ts +5 -2
  207. package/dist/src/telemetry/index.js +3 -2
  208. package/dist/src/telemetry/index.js.map +1 -1
  209. package/dist/src/telemetry/loggers.d.ts +8 -2
  210. package/dist/src/telemetry/loggers.js +130 -2
  211. package/dist/src/telemetry/loggers.js.map +1 -1
  212. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  213. package/dist/src/telemetry/loggers.test.js +105 -9
  214. package/dist/src/telemetry/loggers.test.js.map +1 -1
  215. package/dist/src/telemetry/metrics.d.ts +15 -4
  216. package/dist/src/telemetry/metrics.js +46 -8
  217. package/dist/src/telemetry/metrics.js.map +1 -1
  218. package/dist/src/telemetry/metrics.test.js +5 -25
  219. package/dist/src/telemetry/metrics.test.js.map +1 -1
  220. package/dist/src/telemetry/sdk.d.ts +1 -1
  221. package/dist/src/telemetry/sdk.js +3 -3
  222. package/dist/src/telemetry/sdk.js.map +1 -1
  223. package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
  224. package/dist/src/telemetry/telemetry-utils.js +14 -0
  225. package/dist/src/telemetry/telemetry-utils.js.map +1 -0
  226. package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
  227. package/dist/src/telemetry/telemetry-utils.test.js +40 -0
  228. package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
  229. package/dist/src/telemetry/types.d.ts +61 -6
  230. package/dist/src/telemetry/types.js +105 -4
  231. package/dist/src/telemetry/types.js.map +1 -1
  232. package/dist/src/telemetry/uiTelemetry.d.ts +2 -2
  233. package/dist/src/telemetry/uiTelemetry.js +5 -5
  234. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  235. package/dist/src/telemetry/uiTelemetry.test.js +20 -16
  236. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  237. package/dist/src/test-utils/config.d.ts +2 -1
  238. package/dist/src/test-utils/config.js.map +1 -1
  239. package/dist/src/test-utils/index.d.ts +6 -0
  240. package/dist/src/test-utils/index.js +7 -0
  241. package/dist/src/test-utils/index.js.map +1 -0
  242. package/dist/src/test-utils/mock-tool.d.ts +41 -0
  243. package/dist/src/test-utils/mock-tool.js +51 -0
  244. package/dist/src/test-utils/mock-tool.js.map +1 -0
  245. package/dist/src/test-utils/mockWorkspaceContext.d.ts +1 -1
  246. package/dist/src/test-utils/tools.d.ts +3 -2
  247. package/dist/src/test-utils/tools.js.map +1 -1
  248. package/dist/src/tools/diffOptions.d.ts +1 -1
  249. package/dist/src/tools/diffOptions.js +21 -13
  250. package/dist/src/tools/diffOptions.js.map +1 -1
  251. package/dist/src/tools/diffOptions.test.js +58 -22
  252. package/dist/src/tools/diffOptions.test.js.map +1 -1
  253. package/dist/src/tools/edit.d.ts +6 -5
  254. package/dist/src/tools/edit.js +47 -36
  255. package/dist/src/tools/edit.js.map +1 -1
  256. package/dist/src/tools/edit.test.js +77 -12
  257. package/dist/src/tools/edit.test.js.map +1 -1
  258. package/dist/src/tools/glob.d.ts +3 -2
  259. package/dist/src/tools/glob.js +17 -6
  260. package/dist/src/tools/glob.js.map +1 -1
  261. package/dist/src/tools/glob.test.js +29 -4
  262. package/dist/src/tools/glob.test.js.map +1 -1
  263. package/dist/src/tools/grep.d.ts +3 -2
  264. package/dist/src/tools/grep.js +35 -15
  265. package/dist/src/tools/grep.js.map +1 -1
  266. package/dist/src/tools/grep.test.js +26 -3
  267. package/dist/src/tools/grep.test.js.map +1 -1
  268. package/dist/src/tools/ls.d.ts +3 -2
  269. package/dist/src/tools/ls.js +12 -7
  270. package/dist/src/tools/ls.js.map +1 -1
  271. package/dist/src/tools/ls.test.js +7 -2
  272. package/dist/src/tools/ls.test.js.map +1 -1
  273. package/dist/src/tools/mcp-client-manager.d.ts +8 -6
  274. package/dist/src/tools/mcp-client-manager.js +30 -5
  275. package/dist/src/tools/mcp-client-manager.js.map +1 -1
  276. package/dist/src/tools/mcp-client-manager.test.js +20 -1
  277. package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
  278. package/dist/src/tools/mcp-client.d.ts +18 -11
  279. package/dist/src/tools/mcp-client.js +67 -57
  280. package/dist/src/tools/mcp-client.js.map +1 -1
  281. package/dist/src/tools/mcp-client.test.js +29 -4
  282. package/dist/src/tools/mcp-client.test.js.map +1 -1
  283. package/dist/src/tools/mcp-tool.d.ts +6 -4
  284. package/dist/src/tools/mcp-tool.js +21 -11
  285. package/dist/src/tools/mcp-tool.js.map +1 -1
  286. package/dist/src/tools/mcp-tool.test.js +49 -12
  287. package/dist/src/tools/mcp-tool.test.js.map +1 -1
  288. package/dist/src/tools/memoryTool.d.ts +4 -3
  289. package/dist/src/tools/memoryTool.js +15 -38
  290. package/dist/src/tools/memoryTool.js.map +1 -1
  291. package/dist/src/tools/memoryTool.test.js +24 -12
  292. package/dist/src/tools/memoryTool.test.js.map +1 -1
  293. package/dist/src/tools/modifiable-tool.d.ts +2 -2
  294. package/dist/src/tools/modifiable-tool.js +3 -3
  295. package/dist/src/tools/modifiable-tool.js.map +1 -1
  296. package/dist/src/tools/modifiable-tool.test.js +4 -4
  297. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  298. package/dist/src/tools/read-file.d.ts +3 -2
  299. package/dist/src/tools/read-file.js +12 -34
  300. package/dist/src/tools/read-file.js.map +1 -1
  301. package/dist/src/tools/read-file.test.js +9 -6
  302. package/dist/src/tools/read-file.test.js.map +1 -1
  303. package/dist/src/tools/read-many-files.d.ts +3 -2
  304. package/dist/src/tools/read-many-files.js +35 -58
  305. package/dist/src/tools/read-many-files.js.map +1 -1
  306. package/dist/src/tools/read-many-files.test.js +64 -11
  307. package/dist/src/tools/read-many-files.test.js.map +1 -1
  308. package/dist/src/tools/ripGrep.d.ts +47 -0
  309. package/dist/src/tools/ripGrep.js +368 -0
  310. package/dist/src/tools/ripGrep.js.map +1 -0
  311. package/dist/src/tools/ripGrep.test.d.ts +6 -0
  312. package/dist/src/tools/ripGrep.test.js +874 -0
  313. package/dist/src/tools/ripGrep.test.js.map +1 -0
  314. package/dist/src/tools/shell.d.ts +3 -2
  315. package/dist/src/tools/shell.js +30 -25
  316. package/dist/src/tools/shell.js.map +1 -1
  317. package/dist/src/tools/shell.test.js +34 -25
  318. package/dist/src/tools/shell.test.js.map +1 -1
  319. package/dist/src/tools/smart-edit.d.ts +73 -0
  320. package/dist/src/tools/smart-edit.js +607 -0
  321. package/dist/src/tools/smart-edit.js.map +1 -0
  322. package/dist/src/tools/smart-edit.test.d.ts +6 -0
  323. package/dist/src/tools/smart-edit.test.js +405 -0
  324. package/dist/src/tools/smart-edit.test.js.map +1 -0
  325. package/dist/src/tools/tool-error.d.ts +17 -1
  326. package/dist/src/tools/tool-error.js +26 -0
  327. package/dist/src/tools/tool-error.js.map +1 -1
  328. package/dist/src/tools/tool-registry.d.ts +10 -4
  329. package/dist/src/tools/tool-registry.js +19 -7
  330. package/dist/src/tools/tool-registry.js.map +1 -1
  331. package/dist/src/tools/tool-registry.test.js +86 -3
  332. package/dist/src/tools/tool-registry.test.js.map +1 -1
  333. package/dist/src/tools/tools.d.ts +15 -9
  334. package/dist/src/tools/tools.js +12 -0
  335. package/dist/src/tools/tools.js.map +1 -1
  336. package/dist/src/tools/tools.test.js +1 -2
  337. package/dist/src/tools/tools.test.js.map +1 -1
  338. package/dist/src/tools/web-fetch.d.ts +3 -2
  339. package/dist/src/tools/web-fetch.js +14 -10
  340. package/dist/src/tools/web-fetch.js.map +1 -1
  341. package/dist/src/tools/web-fetch.test.js +55 -16
  342. package/dist/src/tools/web-fetch.test.js.map +1 -1
  343. package/dist/src/tools/web-search.d.ts +4 -3
  344. package/dist/src/tools/web-search.js +31 -8
  345. package/dist/src/tools/web-search.js.map +1 -1
  346. package/dist/src/tools/web-search.test.js +69 -1
  347. package/dist/src/tools/web-search.test.js.map +1 -1
  348. package/dist/src/tools/write-file.d.ts +4 -3
  349. package/dist/src/tools/write-file.js +14 -14
  350. package/dist/src/tools/write-file.js.map +1 -1
  351. package/dist/src/tools/write-file.test.js +14 -14
  352. package/dist/src/tools/write-file.test.js.map +1 -1
  353. package/dist/src/utils/bfsFileSearch.d.ts +2 -2
  354. package/dist/src/utils/bfsFileSearch.js +2 -2
  355. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  356. package/dist/src/utils/bfsFileSearch.test.js +3 -3
  357. package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
  358. package/dist/src/utils/editCorrector.d.ts +2 -2
  359. package/dist/src/utils/editCorrector.js +1 -1
  360. package/dist/src/utils/editCorrector.js.map +1 -1
  361. package/dist/src/utils/editCorrector.test.js +3 -3
  362. package/dist/src/utils/editCorrector.test.js.map +1 -1
  363. package/dist/src/utils/editor.js +2 -2
  364. package/dist/src/utils/editor.js.map +1 -1
  365. package/dist/src/utils/editor.test.js +2 -2
  366. package/dist/src/utils/editor.test.js.map +1 -1
  367. package/dist/src/utils/environmentContext.d.ts +2 -2
  368. package/dist/src/utils/environmentContext.js +1 -1
  369. package/dist/src/utils/environmentContext.js.map +1 -1
  370. package/dist/src/utils/environmentContext.test.js +1 -1
  371. package/dist/src/utils/environmentContext.test.js.map +1 -1
  372. package/dist/src/utils/errorReporting.d.ts +1 -1
  373. package/dist/src/utils/errors.d.ts +19 -0
  374. package/dist/src/utils/errors.js +32 -0
  375. package/dist/src/utils/errors.js.map +1 -1
  376. package/dist/src/utils/fetch.js +1 -1
  377. package/dist/src/utils/fetch.js.map +1 -1
  378. package/dist/src/utils/fileUtils.d.ts +23 -12
  379. package/dist/src/utils/fileUtils.js +160 -79
  380. package/dist/src/utils/fileUtils.js.map +1 -1
  381. package/dist/src/utils/fileUtils.test.js +314 -21
  382. package/dist/src/utils/fileUtils.test.js.map +1 -1
  383. package/dist/src/utils/filesearch/crawler.d.ts +1 -1
  384. package/dist/src/utils/filesearch/crawler.test.js +2 -2
  385. package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
  386. package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
  387. package/dist/src/utils/filesearch/fileSearch.js +14 -9
  388. package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
  389. package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
  390. package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
  391. package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
  392. package/dist/src/utils/generateContentResponseUtilities.js +1 -13
  393. package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
  394. package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
  395. package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
  396. package/dist/src/utils/getFolderStructure.d.ts +2 -2
  397. package/dist/src/utils/getFolderStructure.js +2 -2
  398. package/dist/src/utils/getFolderStructure.js.map +1 -1
  399. package/dist/src/utils/getFolderStructure.test.js +13 -13
  400. package/dist/src/utils/getFolderStructure.test.js.map +1 -1
  401. package/dist/src/utils/getPty.d.ts +19 -0
  402. package/dist/src/utils/getPty.js +23 -0
  403. package/dist/src/utils/getPty.js.map +1 -0
  404. package/dist/src/utils/gitIgnoreParser.d.ts +1 -0
  405. package/dist/src/utils/gitIgnoreParser.js +104 -13
  406. package/dist/src/utils/gitIgnoreParser.js.map +1 -1
  407. package/dist/src/utils/gitIgnoreParser.test.js +69 -3
  408. package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
  409. package/dist/src/utils/gitUtils.js +2 -2
  410. package/dist/src/utils/gitUtils.js.map +1 -1
  411. package/dist/src/utils/ide-trust.d.ts +10 -0
  412. package/dist/src/utils/ide-trust.js +14 -0
  413. package/dist/src/utils/ide-trust.js.map +1 -0
  414. package/dist/src/utils/ignorePatterns.d.ts +103 -0
  415. package/dist/src/utils/ignorePatterns.js +220 -0
  416. package/dist/src/utils/ignorePatterns.js.map +1 -0
  417. package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
  418. package/dist/src/utils/ignorePatterns.test.js +250 -0
  419. package/dist/src/utils/ignorePatterns.test.js.map +1 -0
  420. package/dist/src/utils/installationManager.d.ts +16 -0
  421. package/dist/src/utils/installationManager.js +50 -0
  422. package/dist/src/utils/installationManager.js.map +1 -0
  423. package/dist/src/utils/installationManager.test.d.ts +6 -0
  424. package/dist/src/utils/installationManager.test.js +83 -0
  425. package/dist/src/utils/installationManager.test.js.map +1 -0
  426. package/dist/src/utils/language-detection.d.ts +6 -0
  427. package/dist/src/utils/language-detection.js +101 -0
  428. package/dist/src/utils/language-detection.js.map +1 -0
  429. package/dist/src/utils/llm-edit-fixer.d.ts +25 -0
  430. package/dist/src/utils/llm-edit-fixer.js +112 -0
  431. package/dist/src/utils/llm-edit-fixer.js.map +1 -0
  432. package/dist/src/utils/memoryDiscovery.d.ts +7 -6
  433. package/dist/src/utils/memoryDiscovery.js +68 -33
  434. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  435. package/dist/src/utils/memoryDiscovery.test.js +76 -20
  436. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  437. package/dist/src/utils/memoryImportProcessor.js +2 -2
  438. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  439. package/dist/src/utils/memoryImportProcessor.test.js +2 -141
  440. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  441. package/dist/src/utils/messageInspectors.d.ts +1 -1
  442. package/dist/src/utils/nextSpeakerChecker.d.ts +2 -2
  443. package/dist/src/utils/nextSpeakerChecker.test.js +33 -0
  444. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  445. package/dist/src/utils/partUtils.d.ts +22 -1
  446. package/dist/src/utils/partUtils.js +68 -0
  447. package/dist/src/utils/partUtils.js.map +1 -1
  448. package/dist/src/utils/partUtils.test.js +112 -1
  449. package/dist/src/utils/partUtils.test.js.map +1 -1
  450. package/dist/src/utils/pathReader.d.ts +17 -0
  451. package/dist/src/utils/pathReader.js +92 -0
  452. package/dist/src/utils/pathReader.js.map +1 -0
  453. package/dist/src/utils/pathReader.test.d.ts +6 -0
  454. package/dist/src/utils/pathReader.test.js +363 -0
  455. package/dist/src/utils/pathReader.test.js.map +1 -0
  456. package/dist/src/utils/paths.d.ts +1 -18
  457. package/dist/src/utils/paths.js +3 -29
  458. package/dist/src/utils/paths.js.map +1 -1
  459. package/dist/src/utils/quotaErrorDetection.d.ts +1 -1
  460. package/dist/src/utils/retry.test.js +4 -1
  461. package/dist/src/utils/retry.test.js.map +1 -1
  462. package/dist/src/utils/schemaValidator.js +4 -0
  463. package/dist/src/utils/schemaValidator.js.map +1 -1
  464. package/dist/src/utils/session.js +1 -1
  465. package/dist/src/utils/session.js.map +1 -1
  466. package/dist/src/utils/shell-utils.d.ts +1 -1
  467. package/dist/src/utils/shell-utils.js +23 -29
  468. package/dist/src/utils/shell-utils.js.map +1 -1
  469. package/dist/src/utils/shell-utils.test.js +7 -0
  470. package/dist/src/utils/shell-utils.test.js.map +1 -1
  471. package/dist/src/utils/summarizer.d.ts +2 -2
  472. package/dist/src/utils/summarizer.test.js.map +1 -1
  473. package/dist/src/utils/systemEncoding.js +2 -2
  474. package/dist/src/utils/systemEncoding.js.map +1 -1
  475. package/dist/src/utils/systemEncoding.test.js +2 -2
  476. package/dist/src/utils/systemEncoding.test.js.map +1 -1
  477. package/dist/src/utils/tool-utils.d.ts +19 -0
  478. package/dist/src/utils/tool-utils.js +58 -0
  479. package/dist/src/utils/tool-utils.js.map +1 -0
  480. package/dist/src/utils/tool-utils.test.d.ts +6 -0
  481. package/dist/src/utils/tool-utils.test.js +61 -0
  482. package/dist/src/utils/tool-utils.test.js.map +1 -0
  483. package/dist/src/utils/userAccountManager.d.ts +20 -0
  484. package/dist/src/utils/userAccountManager.js +114 -0
  485. package/dist/src/utils/userAccountManager.js.map +1 -0
  486. package/dist/src/utils/userAccountManager.test.d.ts +6 -0
  487. package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +33 -30
  488. package/dist/src/utils/userAccountManager.test.js.map +1 -0
  489. package/dist/src/utils/workspaceContext.js +13 -7
  490. package/dist/src/utils/workspaceContext.js.map +1 -1
  491. package/dist/src/utils/workspaceContext.test.js +41 -16
  492. package/dist/src/utils/workspaceContext.test.js.map +1 -1
  493. package/dist/tsconfig.tsbuildinfo +1 -1
  494. package/package.json +27 -13
  495. package/dist/src/utils/user_account.d.ts +0 -9
  496. package/dist/src/utils/user_account.js +0 -109
  497. package/dist/src/utils/user_account.js.map +0 -1
  498. package/dist/src/utils/user_account.test.js.map +0 -1
  499. package/dist/src/utils/user_id.d.ts +0 -11
  500. package/dist/src/utils/user_id.js +0 -49
  501. package/dist/src/utils/user_id.js.map +0 -1
  502. package/dist/src/utils/user_id.test.js +0 -21
  503. package/dist/src/utils/user_id.test.js.map +0 -1
  504. /package/dist/src/{utils/user_account.test.d.ts → config/storage.test.d.ts} +0 -0
  505. /package/dist/src/{utils/user_id.test.d.ts → ide/process-utils.test.d.ts} +0 -0
@@ -7,12 +7,87 @@ import { describe, it, expect, vi } from 'vitest';
7
7
  import { CoreToolScheduler, convertToFunctionResponse, } from './coreToolScheduler.js';
8
8
  import { BaseDeclarativeTool, BaseToolInvocation, ToolConfirmationOutcome, Kind, ApprovalMode, } from '../index.js';
9
9
  import { MockModifiableTool, MockTool } from '../test-utils/tools.js';
10
+ class TestApprovalTool extends BaseDeclarativeTool {
11
+ config;
12
+ static Name = 'testApprovalTool';
13
+ constructor(config) {
14
+ super(TestApprovalTool.Name, 'TestApprovalTool', 'A tool for testing approval logic', Kind.Edit, {
15
+ properties: { id: { type: 'string' } },
16
+ required: ['id'],
17
+ type: 'object',
18
+ });
19
+ this.config = config;
20
+ }
21
+ createInvocation(params) {
22
+ return new TestApprovalInvocation(this.config, params);
23
+ }
24
+ }
25
+ class TestApprovalInvocation extends BaseToolInvocation {
26
+ config;
27
+ constructor(config, params) {
28
+ super(params);
29
+ this.config = config;
30
+ }
31
+ getDescription() {
32
+ return `Test tool ${this.params.id}`;
33
+ }
34
+ async shouldConfirmExecute() {
35
+ // Need confirmation unless approval mode is AUTO_EDIT
36
+ if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
37
+ return false;
38
+ }
39
+ return {
40
+ type: 'edit',
41
+ title: `Confirm Test Tool ${this.params.id}`,
42
+ fileName: `test-${this.params.id}.txt`,
43
+ filePath: `/test-${this.params.id}.txt`,
44
+ fileDiff: 'Test diff content',
45
+ originalContent: '',
46
+ newContent: 'Test content',
47
+ onConfirm: async (outcome) => {
48
+ if (outcome === ToolConfirmationOutcome.ProceedAlways) {
49
+ this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
50
+ }
51
+ },
52
+ };
53
+ }
54
+ async execute() {
55
+ return {
56
+ llmContent: `Executed test tool ${this.params.id}`,
57
+ returnDisplay: `Executed test tool ${this.params.id}`,
58
+ };
59
+ }
60
+ }
61
+ async function waitForStatus(onToolCallsUpdate, status, timeout = 5000) {
62
+ return new Promise((resolve, reject) => {
63
+ const startTime = Date.now();
64
+ const check = () => {
65
+ if (Date.now() - startTime > timeout) {
66
+ const seenStatuses = onToolCallsUpdate.mock.calls
67
+ .flatMap((call) => call[0])
68
+ .map((toolCall) => toolCall.status);
69
+ reject(new Error(`Timed out waiting for status "${status}". Seen statuses: ${seenStatuses.join(', ')}`));
70
+ return;
71
+ }
72
+ const foundCall = onToolCallsUpdate.mock.calls
73
+ .flatMap((call) => call[0])
74
+ .find((toolCall) => toolCall.status === status);
75
+ if (foundCall) {
76
+ resolve(foundCall);
77
+ }
78
+ else {
79
+ setTimeout(check, 10); // Check again in 10ms
80
+ }
81
+ };
82
+ check();
83
+ });
84
+ }
10
85
  describe('CoreToolScheduler', () => {
11
86
  it('should cancel a tool call if the signal is aborted before confirmation', async () => {
12
87
  const mockTool = new MockTool();
13
88
  mockTool.shouldConfirm = true;
14
89
  const declarativeTool = mockTool;
15
- const toolRegistry = {
90
+ const mockToolRegistry = {
16
91
  getTool: () => declarativeTool,
17
92
  getFunctionDeclarations: () => [],
18
93
  tools: new Map(),
@@ -32,14 +107,17 @@ describe('CoreToolScheduler', () => {
32
107
  getUsageStatisticsEnabled: () => true,
33
108
  getDebugMode: () => false,
34
109
  getApprovalMode: () => ApprovalMode.DEFAULT,
110
+ getAllowedTools: () => [],
35
111
  getContentGeneratorConfig: () => ({
36
112
  model: 'test-model',
37
113
  authType: 'oauth-personal',
38
114
  }),
115
+ getToolRegistry: () => mockToolRegistry,
116
+ getUseSmartEdit: () => false,
117
+ getGeminiClient: () => null, // No client needed for these tests
39
118
  };
40
119
  const scheduler = new CoreToolScheduler({
41
120
  config: mockConfig,
42
- toolRegistry: Promise.resolve(toolRegistry),
43
121
  onAllToolCallsComplete,
44
122
  onToolCallsUpdate,
45
123
  getPreferredEditor: () => 'vscode',
@@ -60,12 +138,43 @@ describe('CoreToolScheduler', () => {
60
138
  .calls[0][0];
61
139
  expect(completedCalls[0].status).toBe('cancelled');
62
140
  });
141
+ describe('getToolSuggestion', () => {
142
+ it('should suggest the top N closest tool names for a typo', () => {
143
+ // Create mocked tool registry
144
+ const mockConfig = {
145
+ getToolRegistry: () => mockToolRegistry,
146
+ getUseSmartEdit: () => false,
147
+ getGeminiClient: () => null, // No client needed for these tests
148
+ };
149
+ const mockToolRegistry = {
150
+ getAllToolNames: () => ['list_files', 'read_file', 'write_file'],
151
+ };
152
+ // Create scheduler
153
+ const scheduler = new CoreToolScheduler({
154
+ config: mockConfig,
155
+ getPreferredEditor: () => 'vscode',
156
+ onEditorClose: vi.fn(),
157
+ });
158
+ // Test that the right tool is selected, with only 1 result, for typos
159
+ // @ts-expect-error accessing private method
160
+ const misspelledTool = scheduler.getToolSuggestion('list_fils', 1);
161
+ expect(misspelledTool).toBe(' Did you mean "list_files"?');
162
+ // Test that the right tool is selected, with only 1 result, for prefixes
163
+ // @ts-expect-error accessing private method
164
+ const prefixedTool = scheduler.getToolSuggestion('github.list_files', 1);
165
+ expect(prefixedTool).toBe(' Did you mean "list_files"?');
166
+ // Test that the right tool is first
167
+ // @ts-expect-error accessing private method
168
+ const suggestionMultiple = scheduler.getToolSuggestion('list_fils');
169
+ expect(suggestionMultiple).toBe(' Did you mean one of: "list_files", "read_file", "write_file"?');
170
+ });
171
+ });
63
172
  });
64
173
  describe('CoreToolScheduler with payload', () => {
65
174
  it('should update args and diff and execute tool when payload is provided', async () => {
66
175
  const mockTool = new MockModifiableTool();
67
176
  const declarativeTool = mockTool;
68
- const toolRegistry = {
177
+ const mockToolRegistry = {
69
178
  getTool: () => declarativeTool,
70
179
  getFunctionDeclarations: () => [],
71
180
  tools: new Map(),
@@ -85,14 +194,17 @@ describe('CoreToolScheduler with payload', () => {
85
194
  getUsageStatisticsEnabled: () => true,
86
195
  getDebugMode: () => false,
87
196
  getApprovalMode: () => ApprovalMode.DEFAULT,
197
+ getAllowedTools: () => [],
88
198
  getContentGeneratorConfig: () => ({
89
199
  model: 'test-model',
90
200
  authType: 'oauth-personal',
91
201
  }),
202
+ getToolRegistry: () => mockToolRegistry,
203
+ getUseSmartEdit: () => false,
204
+ getGeminiClient: () => null, // No client needed for these tests
92
205
  };
93
206
  const scheduler = new CoreToolScheduler({
94
207
  config: mockConfig,
95
- toolRegistry: Promise.resolve(toolRegistry),
96
208
  onAllToolCallsComplete,
97
209
  onToolCallsUpdate,
98
210
  getPreferredEditor: () => 'vscode',
@@ -107,11 +219,7 @@ describe('CoreToolScheduler with payload', () => {
107
219
  prompt_id: 'prompt-id-2',
108
220
  };
109
221
  await scheduler.schedule([request], abortController.signal);
110
- await vi.waitFor(() => {
111
- const awaitingCall = onToolCallsUpdate.mock.calls.find((call) => call[0][0].status === 'awaiting_approval')?.[0][0];
112
- expect(awaitingCall).toBeDefined();
113
- });
114
- const awaitingCall = onToolCallsUpdate.mock.calls.find((call) => call[0][0].status === 'awaiting_approval')?.[0][0];
222
+ const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
115
223
  const confirmationDetails = awaitingCall.confirmationDetails;
116
224
  if (confirmationDetails) {
117
225
  const payload = { newContent: 'final version' };
@@ -132,35 +240,41 @@ describe('convertToFunctionResponse', () => {
132
240
  it('should handle simple string llmContent', () => {
133
241
  const llmContent = 'Simple text output';
134
242
  const result = convertToFunctionResponse(toolName, callId, llmContent);
135
- expect(result).toEqual({
136
- functionResponse: {
137
- name: toolName,
138
- id: callId,
139
- response: { output: 'Simple text output' },
243
+ expect(result).toEqual([
244
+ {
245
+ functionResponse: {
246
+ name: toolName,
247
+ id: callId,
248
+ response: { output: 'Simple text output' },
249
+ },
140
250
  },
141
- });
251
+ ]);
142
252
  });
143
253
  it('should handle llmContent as a single Part with text', () => {
144
254
  const llmContent = { text: 'Text from Part object' };
145
255
  const result = convertToFunctionResponse(toolName, callId, llmContent);
146
- expect(result).toEqual({
147
- functionResponse: {
148
- name: toolName,
149
- id: callId,
150
- response: { output: 'Text from Part object' },
256
+ expect(result).toEqual([
257
+ {
258
+ functionResponse: {
259
+ name: toolName,
260
+ id: callId,
261
+ response: { output: 'Text from Part object' },
262
+ },
151
263
  },
152
- });
264
+ ]);
153
265
  });
154
266
  it('should handle llmContent as a PartListUnion array with a single text Part', () => {
155
267
  const llmContent = [{ text: 'Text from array' }];
156
268
  const result = convertToFunctionResponse(toolName, callId, llmContent);
157
- expect(result).toEqual({
158
- functionResponse: {
159
- name: toolName,
160
- id: callId,
161
- response: { output: 'Text from array' },
269
+ expect(result).toEqual([
270
+ {
271
+ functionResponse: {
272
+ name: toolName,
273
+ id: callId,
274
+ response: { output: 'Text from array' },
275
+ },
162
276
  },
163
- });
277
+ ]);
164
278
  });
165
279
  it('should handle llmContent with inlineData', () => {
166
280
  const llmContent = {
@@ -237,24 +351,28 @@ describe('convertToFunctionResponse', () => {
237
351
  it('should handle llmContent as a generic Part (not text, inlineData, or fileData)', () => {
238
352
  const llmContent = { functionCall: { name: 'test', args: {} } };
239
353
  const result = convertToFunctionResponse(toolName, callId, llmContent);
240
- expect(result).toEqual({
241
- functionResponse: {
242
- name: toolName,
243
- id: callId,
244
- response: { output: 'Tool execution succeeded.' },
354
+ expect(result).toEqual([
355
+ {
356
+ functionResponse: {
357
+ name: toolName,
358
+ id: callId,
359
+ response: { output: 'Tool execution succeeded.' },
360
+ },
245
361
  },
246
- });
362
+ ]);
247
363
  });
248
364
  it('should handle empty string llmContent', () => {
249
365
  const llmContent = '';
250
366
  const result = convertToFunctionResponse(toolName, callId, llmContent);
251
- expect(result).toEqual({
252
- functionResponse: {
253
- name: toolName,
254
- id: callId,
255
- response: { output: '' },
367
+ expect(result).toEqual([
368
+ {
369
+ functionResponse: {
370
+ name: toolName,
371
+ id: callId,
372
+ response: { output: '' },
373
+ },
256
374
  },
257
- });
375
+ ]);
258
376
  });
259
377
  it('should handle llmContent as an empty array', () => {
260
378
  const llmContent = [];
@@ -272,13 +390,15 @@ describe('convertToFunctionResponse', () => {
272
390
  it('should handle llmContent as a Part with undefined inlineData/fileData/text', () => {
273
391
  const llmContent = {}; // An empty part object
274
392
  const result = convertToFunctionResponse(toolName, callId, llmContent);
275
- expect(result).toEqual({
276
- functionResponse: {
277
- name: toolName,
278
- id: callId,
279
- response: { output: 'Tool execution succeeded.' },
393
+ expect(result).toEqual([
394
+ {
395
+ functionResponse: {
396
+ name: toolName,
397
+ id: callId,
398
+ response: { output: 'Tool execution succeeded.' },
399
+ },
280
400
  },
281
- });
401
+ ]);
282
402
  });
283
403
  });
284
404
  class MockEditToolInvocation extends BaseToolInvocation {
@@ -318,15 +438,14 @@ class MockEditTool extends BaseDeclarativeTool {
318
438
  describe('CoreToolScheduler edit cancellation', () => {
319
439
  it('should preserve diff when an edit is cancelled', async () => {
320
440
  const mockEditTool = new MockEditTool();
321
- const declarativeTool = mockEditTool;
322
- const toolRegistry = {
323
- getTool: () => declarativeTool,
441
+ const mockToolRegistry = {
442
+ getTool: () => mockEditTool,
324
443
  getFunctionDeclarations: () => [],
325
444
  tools: new Map(),
326
445
  discovery: {},
327
446
  registerTool: () => { },
328
- getToolByName: () => declarativeTool,
329
- getToolByDisplayName: () => declarativeTool,
447
+ getToolByName: () => mockEditTool,
448
+ getToolByDisplayName: () => mockEditTool,
330
449
  getTools: () => [],
331
450
  discoverTools: async () => { },
332
451
  getAllTools: () => [],
@@ -339,14 +458,17 @@ describe('CoreToolScheduler edit cancellation', () => {
339
458
  getUsageStatisticsEnabled: () => true,
340
459
  getDebugMode: () => false,
341
460
  getApprovalMode: () => ApprovalMode.DEFAULT,
461
+ getAllowedTools: () => [],
342
462
  getContentGeneratorConfig: () => ({
343
463
  model: 'test-model',
344
464
  authType: 'oauth-personal',
345
465
  }),
466
+ getToolRegistry: () => mockToolRegistry,
467
+ getUseSmartEdit: () => false,
468
+ getGeminiClient: () => null, // No client needed for these tests
346
469
  };
347
470
  const scheduler = new CoreToolScheduler({
348
471
  config: mockConfig,
349
- toolRegistry: Promise.resolve(toolRegistry),
350
472
  onAllToolCallsComplete,
351
473
  onToolCallsUpdate,
352
474
  getPreferredEditor: () => 'vscode',
@@ -361,9 +483,7 @@ describe('CoreToolScheduler edit cancellation', () => {
361
483
  prompt_id: 'prompt-id-1',
362
484
  };
363
485
  await scheduler.schedule([request], abortController.signal);
364
- // Wait for the tool to reach awaiting_approval state
365
- const awaitingCall = onToolCallsUpdate.mock.calls.find((call) => call[0][0].status === 'awaiting_approval')?.[0][0];
366
- expect(awaitingCall).toBeDefined();
486
+ const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
367
487
  // Cancel the edit
368
488
  const confirmationDetails = awaitingCall.confirmationDetails;
369
489
  if (confirmationDetails) {
@@ -392,7 +512,7 @@ describe('CoreToolScheduler YOLO mode', () => {
392
512
  // This tool would normally require confirmation.
393
513
  mockTool.shouldConfirm = true;
394
514
  const declarativeTool = mockTool;
395
- const toolRegistry = {
515
+ const mockToolRegistry = {
396
516
  getTool: () => declarativeTool,
397
517
  getToolByName: () => declarativeTool,
398
518
  // Other properties are not needed for this test but are included for type consistency.
@@ -414,14 +534,17 @@ describe('CoreToolScheduler YOLO mode', () => {
414
534
  getUsageStatisticsEnabled: () => true,
415
535
  getDebugMode: () => false,
416
536
  getApprovalMode: () => ApprovalMode.YOLO,
537
+ getAllowedTools: () => [],
417
538
  getContentGeneratorConfig: () => ({
418
539
  model: 'test-model',
419
540
  authType: 'oauth-personal',
420
541
  }),
542
+ getToolRegistry: () => mockToolRegistry,
543
+ getUseSmartEdit: () => false,
544
+ getGeminiClient: () => null, // No client needed for these tests
421
545
  };
422
546
  const scheduler = new CoreToolScheduler({
423
547
  config: mockConfig,
424
- toolRegistry: Promise.resolve(toolRegistry),
425
548
  onAllToolCallsComplete,
426
549
  onToolCallsUpdate,
427
550
  getPreferredEditor: () => 'vscode',
@@ -472,7 +595,7 @@ describe('CoreToolScheduler request queueing', () => {
472
595
  const mockTool = new MockTool();
473
596
  mockTool.executeFn.mockImplementation(() => firstCallPromise);
474
597
  const declarativeTool = mockTool;
475
- const toolRegistry = {
598
+ const mockToolRegistry = {
476
599
  getTool: () => declarativeTool,
477
600
  getToolByName: () => declarativeTool,
478
601
  getFunctionDeclarations: () => [],
@@ -492,14 +615,17 @@ describe('CoreToolScheduler request queueing', () => {
492
615
  getUsageStatisticsEnabled: () => true,
493
616
  getDebugMode: () => false,
494
617
  getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
618
+ getAllowedTools: () => [],
495
619
  getContentGeneratorConfig: () => ({
496
620
  model: 'test-model',
497
621
  authType: 'oauth-personal',
498
622
  }),
623
+ getToolRegistry: () => mockToolRegistry,
624
+ getUseSmartEdit: () => false,
625
+ getGeminiClient: () => null, // No client needed for these tests
499
626
  };
500
627
  const scheduler = new CoreToolScheduler({
501
628
  config: mockConfig,
502
- toolRegistry: Promise.resolve(toolRegistry),
503
629
  onAllToolCallsComplete,
504
630
  onToolCallsUpdate,
505
631
  getPreferredEditor: () => 'vscode',
@@ -523,10 +649,7 @@ describe('CoreToolScheduler request queueing', () => {
523
649
  // Schedule the first call, which will pause execution.
524
650
  scheduler.schedule([request1], abortController.signal);
525
651
  // Wait for the first call to be in the 'executing' state.
526
- await vi.waitFor(() => {
527
- const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
528
- expect(calls?.[0]?.status).toBe('executing');
529
- });
652
+ await waitForStatus(onToolCallsUpdate, 'executing');
530
653
  // Schedule the second call while the first is "running".
531
654
  const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
532
655
  // Ensure the second tool call hasn't been executed yet.
@@ -539,14 +662,6 @@ describe('CoreToolScheduler request queueing', () => {
539
662
  });
540
663
  // Wait for the second schedule promise to resolve.
541
664
  await schedulePromise2;
542
- // Wait for the second call to be in the 'executing' state.
543
- await vi.waitFor(() => {
544
- const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
545
- expect(calls?.[0]?.status).toBe('executing');
546
- });
547
- // Now the second tool call should have been executed.
548
- expect(mockTool.executeFn).toHaveBeenCalledTimes(2);
549
- expect(mockTool.executeFn).toHaveBeenCalledWith({ b: 2 });
550
665
  // Let the second call finish.
551
666
  const secondCallResult = {
552
667
  llmContent: 'Second call complete',
@@ -555,6 +670,11 @@ describe('CoreToolScheduler request queueing', () => {
555
670
  // Since the mock is shared, we need to resolve the current promise.
556
671
  // In a real scenario, a new promise would be created for the second call.
557
672
  resolveFirstCall(secondCallResult);
673
+ await vi.waitFor(() => {
674
+ // Now the second tool call should have been executed.
675
+ expect(mockTool.executeFn).toHaveBeenCalledTimes(2);
676
+ });
677
+ expect(mockTool.executeFn).toHaveBeenCalledWith({ b: 2 });
558
678
  // Wait for the second completion.
559
679
  await vi.waitFor(() => {
560
680
  expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
@@ -563,10 +683,92 @@ describe('CoreToolScheduler request queueing', () => {
563
683
  expect(onAllToolCallsComplete.mock.calls[0][0][0].status).toBe('success');
564
684
  expect(onAllToolCallsComplete.mock.calls[1][0][0].status).toBe('success');
565
685
  });
686
+ it('should auto-approve a tool call if it is on the allowedTools list', async () => {
687
+ // Arrange
688
+ const mockTool = new MockTool('mockTool');
689
+ mockTool.executeFn.mockReturnValue({
690
+ llmContent: 'Tool executed',
691
+ returnDisplay: 'Tool executed',
692
+ });
693
+ // This tool would normally require confirmation.
694
+ mockTool.shouldConfirm = true;
695
+ const declarativeTool = mockTool;
696
+ const toolRegistry = {
697
+ getTool: () => declarativeTool,
698
+ getToolByName: () => declarativeTool,
699
+ getFunctionDeclarations: () => [],
700
+ tools: new Map(),
701
+ discovery: {},
702
+ registerTool: () => { },
703
+ getToolByDisplayName: () => declarativeTool,
704
+ getTools: () => [],
705
+ discoverTools: async () => { },
706
+ getAllTools: () => [],
707
+ getToolsByServer: () => [],
708
+ };
709
+ const onAllToolCallsComplete = vi.fn();
710
+ const onToolCallsUpdate = vi.fn();
711
+ // Configure the scheduler to auto-approve the specific tool call.
712
+ const mockConfig = {
713
+ getSessionId: () => 'test-session-id',
714
+ getUsageStatisticsEnabled: () => true,
715
+ getDebugMode: () => false,
716
+ getApprovalMode: () => ApprovalMode.DEFAULT, // Not YOLO mode
717
+ getAllowedTools: () => ['mockTool'], // Auto-approve this tool
718
+ getToolRegistry: () => toolRegistry,
719
+ getContentGeneratorConfig: () => ({
720
+ model: 'test-model',
721
+ authType: 'oauth-personal',
722
+ }),
723
+ getUseSmartEdit: () => false,
724
+ getGeminiClient: () => null, // No client needed for these tests
725
+ };
726
+ const scheduler = new CoreToolScheduler({
727
+ config: mockConfig,
728
+ onAllToolCallsComplete,
729
+ onToolCallsUpdate,
730
+ getPreferredEditor: () => 'vscode',
731
+ onEditorClose: vi.fn(),
732
+ });
733
+ const abortController = new AbortController();
734
+ const request = {
735
+ callId: '1',
736
+ name: 'mockTool',
737
+ args: { param: 'value' },
738
+ isClientInitiated: false,
739
+ prompt_id: 'prompt-auto-approved',
740
+ };
741
+ // Act
742
+ await scheduler.schedule([request], abortController.signal);
743
+ // Assert
744
+ // 1. The tool's execute method was called directly.
745
+ expect(mockTool.executeFn).toHaveBeenCalledWith({ param: 'value' });
746
+ // 2. The tool call status never entered 'awaiting_approval'.
747
+ const statusUpdates = onToolCallsUpdate.mock.calls
748
+ .map((call) => call[0][0]?.status)
749
+ .filter(Boolean);
750
+ expect(statusUpdates).not.toContain('awaiting_approval');
751
+ expect(statusUpdates).toEqual([
752
+ 'validating',
753
+ 'scheduled',
754
+ 'executing',
755
+ 'success',
756
+ ]);
757
+ // 3. The final callback indicates the tool call was successful.
758
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
759
+ const completedCalls = onAllToolCallsComplete.mock
760
+ .calls[0][0];
761
+ expect(completedCalls).toHaveLength(1);
762
+ const completedCall = completedCalls[0];
763
+ expect(completedCall.status).toBe('success');
764
+ if (completedCall.status === 'success') {
765
+ expect(completedCall.response.resultDisplay).toBe('Tool executed');
766
+ }
767
+ });
566
768
  it('should handle two synchronous calls to schedule', async () => {
567
769
  const mockTool = new MockTool();
568
770
  const declarativeTool = mockTool;
569
- const toolRegistry = {
771
+ const mockToolRegistry = {
570
772
  getTool: () => declarativeTool,
571
773
  getToolByName: () => declarativeTool,
572
774
  getFunctionDeclarations: () => [],
@@ -586,14 +788,17 @@ describe('CoreToolScheduler request queueing', () => {
586
788
  getUsageStatisticsEnabled: () => true,
587
789
  getDebugMode: () => false,
588
790
  getApprovalMode: () => ApprovalMode.YOLO,
791
+ getAllowedTools: () => [],
589
792
  getContentGeneratorConfig: () => ({
590
793
  model: 'test-model',
591
794
  authType: 'oauth-personal',
592
795
  }),
796
+ getToolRegistry: () => mockToolRegistry,
797
+ getUseSmartEdit: () => false,
798
+ getGeminiClient: () => null, // No client needed for these tests
593
799
  };
594
800
  const scheduler = new CoreToolScheduler({
595
801
  config: mockConfig,
596
- toolRegistry: Promise.resolve(toolRegistry),
597
802
  onAllToolCallsComplete,
598
803
  onToolCallsUpdate,
599
804
  getPreferredEditor: () => 'vscode',
@@ -626,5 +831,111 @@ describe('CoreToolScheduler request queueing', () => {
626
831
  // Ensure completion callbacks were called twice.
627
832
  expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
628
833
  });
834
+ it('should auto-approve remaining tool calls when first tool call is approved with ProceedAlways', async () => {
835
+ let approvalMode = ApprovalMode.DEFAULT;
836
+ const mockConfig = {
837
+ getSessionId: () => 'test-session-id',
838
+ getUsageStatisticsEnabled: () => true,
839
+ getDebugMode: () => false,
840
+ getApprovalMode: () => approvalMode,
841
+ getAllowedTools: () => [],
842
+ setApprovalMode: (mode) => {
843
+ approvalMode = mode;
844
+ },
845
+ getUseSmartEdit: () => false,
846
+ getGeminiClient: () => null, // No client needed for these tests
847
+ };
848
+ const testTool = new TestApprovalTool(mockConfig);
849
+ const toolRegistry = {
850
+ getTool: () => testTool,
851
+ getFunctionDeclarations: () => [],
852
+ getFunctionDeclarationsFiltered: () => [],
853
+ registerTool: () => { },
854
+ discoverAllTools: async () => { },
855
+ discoverMcpTools: async () => { },
856
+ discoverToolsForServer: async () => { },
857
+ removeMcpToolsByServer: () => { },
858
+ getAllTools: () => [],
859
+ getToolsByServer: () => [],
860
+ tools: new Map(),
861
+ config: mockConfig,
862
+ mcpClientManager: undefined,
863
+ getToolByName: () => testTool,
864
+ getToolByDisplayName: () => testTool,
865
+ getTools: () => [],
866
+ discoverTools: async () => { },
867
+ discovery: {},
868
+ };
869
+ mockConfig.getToolRegistry = () => toolRegistry;
870
+ const onAllToolCallsComplete = vi.fn();
871
+ const onToolCallsUpdate = vi.fn();
872
+ const pendingConfirmations = [];
873
+ const scheduler = new CoreToolScheduler({
874
+ config: mockConfig,
875
+ onAllToolCallsComplete,
876
+ onToolCallsUpdate: (toolCalls) => {
877
+ onToolCallsUpdate(toolCalls);
878
+ // Capture confirmation handlers for awaiting_approval tools
879
+ toolCalls.forEach((call) => {
880
+ if (call.status === 'awaiting_approval') {
881
+ const waitingCall = call;
882
+ if (waitingCall.confirmationDetails?.onConfirm) {
883
+ const originalHandler = pendingConfirmations.find((h) => h === waitingCall.confirmationDetails.onConfirm);
884
+ if (!originalHandler) {
885
+ pendingConfirmations.push(waitingCall.confirmationDetails.onConfirm);
886
+ }
887
+ }
888
+ }
889
+ });
890
+ },
891
+ getPreferredEditor: () => 'vscode',
892
+ onEditorClose: vi.fn(),
893
+ });
894
+ const abortController = new AbortController();
895
+ // Schedule multiple tools that need confirmation
896
+ const requests = [
897
+ {
898
+ callId: '1',
899
+ name: 'testApprovalTool',
900
+ args: { id: 'first' },
901
+ isClientInitiated: false,
902
+ prompt_id: 'prompt-1',
903
+ },
904
+ {
905
+ callId: '2',
906
+ name: 'testApprovalTool',
907
+ args: { id: 'second' },
908
+ isClientInitiated: false,
909
+ prompt_id: 'prompt-2',
910
+ },
911
+ {
912
+ callId: '3',
913
+ name: 'testApprovalTool',
914
+ args: { id: 'third' },
915
+ isClientInitiated: false,
916
+ prompt_id: 'prompt-3',
917
+ },
918
+ ];
919
+ await scheduler.schedule(requests, abortController.signal);
920
+ // Wait for all tools to be awaiting approval
921
+ await vi.waitFor(() => {
922
+ const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
923
+ expect(calls?.length).toBe(3);
924
+ expect(calls?.every((call) => call.status === 'awaiting_approval')).toBe(true);
925
+ });
926
+ expect(pendingConfirmations.length).toBe(3);
927
+ // Approve the first tool with ProceedAlways
928
+ const firstConfirmation = pendingConfirmations[0];
929
+ firstConfirmation(ToolConfirmationOutcome.ProceedAlways);
930
+ // Wait for all tools to be completed
931
+ await vi.waitFor(() => {
932
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
933
+ const completedCalls = onAllToolCallsComplete.mock.calls.at(-1)?.[0];
934
+ expect(completedCalls?.length).toBe(3);
935
+ expect(completedCalls?.every((call) => call.status === 'success')).toBe(true);
936
+ });
937
+ // Verify approval mode was changed
938
+ expect(approvalMode).toBe(ApprovalMode.AUTO_EDIT);
939
+ });
629
940
  });
630
941
  //# sourceMappingURL=coreToolScheduler.test.js.map