@anh3d0nic/qwen-code-termux-ice 21.0.1 → 21.2.0

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 (1281) hide show
  1. package/bin/qwen-ice +127 -331
  2. package/core/ice-core.js +101 -0
  3. package/core-dist/index.d.ts +6 -0
  4. package/core-dist/index.js +7 -0
  5. package/core-dist/index.js.map +1 -0
  6. package/core-dist/src/__mocks__/fs/promises.d.ts +11 -0
  7. package/core-dist/src/__mocks__/fs/promises.js +17 -0
  8. package/core-dist/src/__mocks__/fs/promises.js.map +1 -0
  9. package/core-dist/src/config/config.d.ts +648 -0
  10. package/core-dist/src/config/config.js +1374 -0
  11. package/core-dist/src/config/config.js.map +1 -0
  12. package/core-dist/src/config/config.test.d.ts +6 -0
  13. package/core-dist/src/config/config.test.js +1116 -0
  14. package/core-dist/src/config/config.test.js.map +1 -0
  15. package/core-dist/src/config/constants.d.ts +11 -0
  16. package/core-dist/src/config/constants.js +16 -0
  17. package/core-dist/src/config/constants.js.map +1 -0
  18. package/core-dist/src/config/models.d.ts +9 -0
  19. package/core-dist/src/config/models.js +10 -0
  20. package/core-dist/src/config/models.js.map +1 -0
  21. package/core-dist/src/config/storage.d.ts +38 -0
  22. package/core-dist/src/config/storage.js +114 -0
  23. package/core-dist/src/config/storage.js.map +1 -0
  24. package/core-dist/src/config/storage.test.d.ts +6 -0
  25. package/core-dist/src/config/storage.test.js +36 -0
  26. package/core-dist/src/config/storage.test.js.map +1 -0
  27. package/core-dist/src/confirmation-bus/message-bus.d.ts +22 -0
  28. package/core-dist/src/confirmation-bus/message-bus.js +98 -0
  29. package/core-dist/src/confirmation-bus/message-bus.js.map +1 -0
  30. package/core-dist/src/confirmation-bus/types.d.ts +104 -0
  31. package/core-dist/src/confirmation-bus/types.js +16 -0
  32. package/core-dist/src/confirmation-bus/types.js.map +1 -0
  33. package/core-dist/src/core/__tests__/openaiTimeoutHandling.test.d.ts +6 -0
  34. package/core-dist/src/core/__tests__/openaiTimeoutHandling.test.js +298 -0
  35. package/core-dist/src/core/__tests__/openaiTimeoutHandling.test.js.map +1 -0
  36. package/core-dist/src/core/__tests__/orphanedToolCallsTest.d.ts +64 -0
  37. package/core-dist/src/core/__tests__/orphanedToolCallsTest.js +122 -0
  38. package/core-dist/src/core/__tests__/orphanedToolCallsTest.js.map +1 -0
  39. package/core-dist/src/core/anthropicContentGenerator/anthropicContentGenerator.d.ts +28 -0
  40. package/core-dist/src/core/anthropicContentGenerator/anthropicContentGenerator.js +349 -0
  41. package/core-dist/src/core/anthropicContentGenerator/anthropicContentGenerator.js.map +1 -0
  42. package/core-dist/src/core/anthropicContentGenerator/anthropicContentGenerator.test.d.ts +6 -0
  43. package/core-dist/src/core/anthropicContentGenerator/anthropicContentGenerator.test.js +396 -0
  44. package/core-dist/src/core/anthropicContentGenerator/anthropicContentGenerator.test.js.map +1 -0
  45. package/core-dist/src/core/anthropicContentGenerator/converter.d.ts +48 -0
  46. package/core-dist/src/core/anthropicContentGenerator/converter.js +449 -0
  47. package/core-dist/src/core/anthropicContentGenerator/converter.js.map +1 -0
  48. package/core-dist/src/core/anthropicContentGenerator/converter.test.d.ts +6 -0
  49. package/core-dist/src/core/anthropicContentGenerator/converter.test.js +843 -0
  50. package/core-dist/src/core/anthropicContentGenerator/converter.test.js.map +1 -0
  51. package/core-dist/src/core/anthropicContentGenerator/index.d.ts +9 -0
  52. package/core-dist/src/core/anthropicContentGenerator/index.js +11 -0
  53. package/core-dist/src/core/anthropicContentGenerator/index.js.map +1 -0
  54. package/core-dist/src/core/baseLlmClient.d.ts +48 -0
  55. package/core-dist/src/core/baseLlmClient.js +98 -0
  56. package/core-dist/src/core/baseLlmClient.js.map +1 -0
  57. package/core-dist/src/core/baseLlmClient.test.d.ts +6 -0
  58. package/core-dist/src/core/baseLlmClient.test.js +319 -0
  59. package/core-dist/src/core/baseLlmClient.test.js.map +1 -0
  60. package/core-dist/src/core/client.d.ts +48 -0
  61. package/core-dist/src/core/client.js +547 -0
  62. package/core-dist/src/core/client.js.map +1 -0
  63. package/core-dist/src/core/client.test.d.ts +6 -0
  64. package/core-dist/src/core/client.test.js +1885 -0
  65. package/core-dist/src/core/client.test.js.map +1 -0
  66. package/core-dist/src/core/contentGenerator.d.ts +100 -0
  67. package/core-dist/src/core/contentGenerator.js +162 -0
  68. package/core-dist/src/core/contentGenerator.js.map +1 -0
  69. package/core-dist/src/core/contentGenerator.test.d.ts +6 -0
  70. package/core-dist/src/core/contentGenerator.test.js +95 -0
  71. package/core-dist/src/core/contentGenerator.test.js.map +1 -0
  72. package/core-dist/src/core/coreToolScheduler.d.ts +142 -0
  73. package/core-dist/src/core/coreToolScheduler.js +872 -0
  74. package/core-dist/src/core/coreToolScheduler.js.map +1 -0
  75. package/core-dist/src/core/coreToolScheduler.test.d.ts +6 -0
  76. package/core-dist/src/core/coreToolScheduler.test.js +2221 -0
  77. package/core-dist/src/core/coreToolScheduler.test.js.map +1 -0
  78. package/core-dist/src/core/geminiChat.d.ts +122 -0
  79. package/core-dist/src/core/geminiChat.js +571 -0
  80. package/core-dist/src/core/geminiChat.js.map +1 -0
  81. package/core-dist/src/core/geminiChat.test.d.ts +6 -0
  82. package/core-dist/src/core/geminiChat.test.js +1276 -0
  83. package/core-dist/src/core/geminiChat.test.js.map +1 -0
  84. package/core-dist/src/core/geminiContentGenerator/geminiContentGenerator.d.ts +38 -0
  85. package/core-dist/src/core/geminiContentGenerator/geminiContentGenerator.js +193 -0
  86. package/core-dist/src/core/geminiContentGenerator/geminiContentGenerator.js.map +1 -0
  87. package/core-dist/src/core/geminiContentGenerator/geminiContentGenerator.test.d.ts +6 -0
  88. package/core-dist/src/core/geminiContentGenerator/geminiContentGenerator.test.js +304 -0
  89. package/core-dist/src/core/geminiContentGenerator/geminiContentGenerator.test.js.map +1 -0
  90. package/core-dist/src/core/geminiContentGenerator/index.d.ts +12 -0
  91. package/core-dist/src/core/geminiContentGenerator/index.js +36 -0
  92. package/core-dist/src/core/geminiContentGenerator/index.js.map +1 -0
  93. package/core-dist/src/core/geminiContentGenerator/index.test.d.ts +6 -0
  94. package/core-dist/src/core/geminiContentGenerator/index.test.js +34 -0
  95. package/core-dist/src/core/geminiContentGenerator/index.test.js.map +1 -0
  96. package/core-dist/src/core/geminiRequest.d.ts +13 -0
  97. package/core-dist/src/core/geminiRequest.js +11 -0
  98. package/core-dist/src/core/geminiRequest.js.map +1 -0
  99. package/core-dist/src/core/geminiRequest.test.d.ts +6 -0
  100. package/core-dist/src/core/geminiRequest.test.js +73 -0
  101. package/core-dist/src/core/geminiRequest.test.js.map +1 -0
  102. package/core-dist/src/core/logger.d.ts +68 -0
  103. package/core-dist/src/core/logger.js +364 -0
  104. package/core-dist/src/core/logger.js.map +1 -0
  105. package/core-dist/src/core/logger.test.d.ts +6 -0
  106. package/core-dist/src/core/logger.test.js +520 -0
  107. package/core-dist/src/core/logger.test.js.map +1 -0
  108. package/core-dist/src/core/loggingContentGenerator/index.d.ts +6 -0
  109. package/core-dist/src/core/loggingContentGenerator/index.js +7 -0
  110. package/core-dist/src/core/loggingContentGenerator/index.js.map +1 -0
  111. package/core-dist/src/core/loggingContentGenerator/loggingContentGenerator.d.ts +36 -0
  112. package/core-dist/src/core/loggingContentGenerator/loggingContentGenerator.js +321 -0
  113. package/core-dist/src/core/loggingContentGenerator/loggingContentGenerator.js.map +1 -0
  114. package/core-dist/src/core/loggingContentGenerator/loggingContentGenerator.test.d.ts +6 -0
  115. package/core-dist/src/core/loggingContentGenerator/loggingContentGenerator.test.js +287 -0
  116. package/core-dist/src/core/loggingContentGenerator/loggingContentGenerator.test.js.map +1 -0
  117. package/core-dist/src/core/modalityDefaults.d.ts +14 -0
  118. package/core-dist/src/core/modalityDefaults.js +81 -0
  119. package/core-dist/src/core/modalityDefaults.js.map +1 -0
  120. package/core-dist/src/core/modalityDefaults.test.d.ts +6 -0
  121. package/core-dist/src/core/modalityDefaults.test.js +181 -0
  122. package/core-dist/src/core/modalityDefaults.test.js.map +1 -0
  123. package/core-dist/src/core/nonInteractiveToolExecutor.d.ts +16 -0
  124. package/core-dist/src/core/nonInteractiveToolExecutor.js +30 -0
  125. package/core-dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
  126. package/core-dist/src/core/nonInteractiveToolExecutor.test.d.ts +6 -0
  127. package/core-dist/src/core/nonInteractiveToolExecutor.test.js +296 -0
  128. package/core-dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
  129. package/core-dist/src/core/openaiContentGenerator/constants.d.ts +6 -0
  130. package/core-dist/src/core/openaiContentGenerator/constants.js +7 -0
  131. package/core-dist/src/core/openaiContentGenerator/constants.js.map +1 -0
  132. package/core-dist/src/core/openaiContentGenerator/converter.d.ts +133 -0
  133. package/core-dist/src/core/openaiContentGenerator/converter.js +1020 -0
  134. package/core-dist/src/core/openaiContentGenerator/converter.js.map +1 -0
  135. package/core-dist/src/core/openaiContentGenerator/converter.test.d.ts +6 -0
  136. package/core-dist/src/core/openaiContentGenerator/converter.test.js +1966 -0
  137. package/core-dist/src/core/openaiContentGenerator/converter.test.js.map +1 -0
  138. package/core-dist/src/core/openaiContentGenerator/errorHandler.d.ts +27 -0
  139. package/core-dist/src/core/openaiContentGenerator/errorHandler.js +84 -0
  140. package/core-dist/src/core/openaiContentGenerator/errorHandler.js.map +1 -0
  141. package/core-dist/src/core/openaiContentGenerator/errorHandler.test.d.ts +6 -0
  142. package/core-dist/src/core/openaiContentGenerator/errorHandler.test.js +267 -0
  143. package/core-dist/src/core/openaiContentGenerator/errorHandler.test.js.map +1 -0
  144. package/core-dist/src/core/openaiContentGenerator/index.d.ts +21 -0
  145. package/core-dist/src/core/openaiContentGenerator/index.js +43 -0
  146. package/core-dist/src/core/openaiContentGenerator/index.js.map +1 -0
  147. package/core-dist/src/core/openaiContentGenerator/openaiContentGenerator.d.ts +22 -0
  148. package/core-dist/src/core/openaiContentGenerator/openaiContentGenerator.js +117 -0
  149. package/core-dist/src/core/openaiContentGenerator/openaiContentGenerator.js.map +1 -0
  150. package/core-dist/src/core/openaiContentGenerator/openaiContentGenerator.test.d.ts +6 -0
  151. package/core-dist/src/core/openaiContentGenerator/openaiContentGenerator.test.js +298 -0
  152. package/core-dist/src/core/openaiContentGenerator/openaiContentGenerator.test.js.map +1 -0
  153. package/core-dist/src/core/openaiContentGenerator/pipeline.d.ts +74 -0
  154. package/core-dist/src/core/openaiContentGenerator/pipeline.js +327 -0
  155. package/core-dist/src/core/openaiContentGenerator/pipeline.js.map +1 -0
  156. package/core-dist/src/core/openaiContentGenerator/pipeline.test.d.ts +6 -0
  157. package/core-dist/src/core/openaiContentGenerator/pipeline.test.js +1143 -0
  158. package/core-dist/src/core/openaiContentGenerator/pipeline.test.js.map +1 -0
  159. package/core-dist/src/core/openaiContentGenerator/provider/README.md +61 -0
  160. package/core-dist/src/core/openaiContentGenerator/provider/dashscope.d.ts +70 -0
  161. package/core-dist/src/core/openaiContentGenerator/provider/dashscope.js +258 -0
  162. package/core-dist/src/core/openaiContentGenerator/provider/dashscope.js.map +1 -0
  163. package/core-dist/src/core/openaiContentGenerator/provider/dashscope.test.d.ts +6 -0
  164. package/core-dist/src/core/openaiContentGenerator/provider/dashscope.test.js +781 -0
  165. package/core-dist/src/core/openaiContentGenerator/provider/dashscope.test.js.map +1 -0
  166. package/core-dist/src/core/openaiContentGenerator/provider/deepseek.d.ts +14 -0
  167. package/core-dist/src/core/openaiContentGenerator/provider/deepseek.js +21 -0
  168. package/core-dist/src/core/openaiContentGenerator/provider/deepseek.js.map +1 -0
  169. package/core-dist/src/core/openaiContentGenerator/provider/deepseek.test.d.ts +6 -0
  170. package/core-dist/src/core/openaiContentGenerator/provider/deepseek.test.js +51 -0
  171. package/core-dist/src/core/openaiContentGenerator/provider/deepseek.test.js.map +1 -0
  172. package/core-dist/src/core/openaiContentGenerator/provider/default.d.ts +17 -0
  173. package/core-dist/src/core/openaiContentGenerator/provider/default.js +52 -0
  174. package/core-dist/src/core/openaiContentGenerator/provider/default.js.map +1 -0
  175. package/core-dist/src/core/openaiContentGenerator/provider/default.test.d.ts +6 -0
  176. package/core-dist/src/core/openaiContentGenerator/provider/default.test.js +227 -0
  177. package/core-dist/src/core/openaiContentGenerator/provider/default.test.js.map +1 -0
  178. package/core-dist/src/core/openaiContentGenerator/provider/index.d.ts +6 -0
  179. package/core-dist/src/core/openaiContentGenerator/provider/index.js +6 -0
  180. package/core-dist/src/core/openaiContentGenerator/provider/index.js.map +1 -0
  181. package/core-dist/src/core/openaiContentGenerator/provider/modelscope.d.ts +17 -0
  182. package/core-dist/src/core/openaiContentGenerator/provider/modelscope.js +25 -0
  183. package/core-dist/src/core/openaiContentGenerator/provider/modelscope.js.map +1 -0
  184. package/core-dist/src/core/openaiContentGenerator/provider/modelscope.test.d.ts +6 -0
  185. package/core-dist/src/core/openaiContentGenerator/provider/modelscope.test.js +66 -0
  186. package/core-dist/src/core/openaiContentGenerator/provider/modelscope.test.js.map +1 -0
  187. package/core-dist/src/core/openaiContentGenerator/provider/openrouter.d.ts +8 -0
  188. package/core-dist/src/core/openaiContentGenerator/provider/openrouter.js +21 -0
  189. package/core-dist/src/core/openaiContentGenerator/provider/openrouter.js.map +1 -0
  190. package/core-dist/src/core/openaiContentGenerator/provider/openrouter.test.d.ts +6 -0
  191. package/core-dist/src/core/openaiContentGenerator/provider/openrouter.test.js +152 -0
  192. package/core-dist/src/core/openaiContentGenerator/provider/openrouter.test.js.map +1 -0
  193. package/core-dist/src/core/openaiContentGenerator/provider/types.d.ts +26 -0
  194. package/core-dist/src/core/openaiContentGenerator/provider/types.js +2 -0
  195. package/core-dist/src/core/openaiContentGenerator/provider/types.js.map +1 -0
  196. package/core-dist/src/core/openaiContentGenerator/streamingToolCallParser.d.ts +157 -0
  197. package/core-dist/src/core/openaiContentGenerator/streamingToolCallParser.js +390 -0
  198. package/core-dist/src/core/openaiContentGenerator/streamingToolCallParser.js.map +1 -0
  199. package/core-dist/src/core/openaiContentGenerator/streamingToolCallParser.test.d.ts +6 -0
  200. package/core-dist/src/core/openaiContentGenerator/streamingToolCallParser.test.js +585 -0
  201. package/core-dist/src/core/openaiContentGenerator/streamingToolCallParser.test.js.map +1 -0
  202. package/core-dist/src/core/prompts.d.ts +81 -0
  203. package/core-dist/src/core/prompts.js +996 -0
  204. package/core-dist/src/core/prompts.js.map +1 -0
  205. package/core-dist/src/core/prompts.test.d.ts +6 -0
  206. package/core-dist/src/core/prompts.test.js +485 -0
  207. package/core-dist/src/core/prompts.test.js.map +1 -0
  208. package/core-dist/src/core/tokenLimits.d.ts +29 -0
  209. package/core-dist/src/core/tokenLimits.js +171 -0
  210. package/core-dist/src/core/tokenLimits.js.map +1 -0
  211. package/core-dist/src/core/tokenLimits.test.d.ts +1 -0
  212. package/core-dist/src/core/tokenLimits.test.js +270 -0
  213. package/core-dist/src/core/tokenLimits.test.js.map +1 -0
  214. package/core-dist/src/core/turn.d.ts +161 -0
  215. package/core-dist/src/core/turn.js +197 -0
  216. package/core-dist/src/core/turn.js.map +1 -0
  217. package/core-dist/src/core/turn.test.d.ts +6 -0
  218. package/core-dist/src/core/turn.test.js +817 -0
  219. package/core-dist/src/core/turn.test.js.map +1 -0
  220. package/core-dist/src/extension/claude-converter.d.ts +121 -0
  221. package/core-dist/src/extension/claude-converter.js +572 -0
  222. package/core-dist/src/extension/claude-converter.js.map +1 -0
  223. package/core-dist/src/extension/claude-converter.test.d.ts +6 -0
  224. package/core-dist/src/extension/claude-converter.test.js +305 -0
  225. package/core-dist/src/extension/claude-converter.test.js.map +1 -0
  226. package/core-dist/src/extension/extensionManager.d.ts +159 -0
  227. package/core-dist/src/extension/extensionManager.js +829 -0
  228. package/core-dist/src/extension/extensionManager.js.map +1 -0
  229. package/core-dist/src/extension/extensionManager.test.d.ts +6 -0
  230. package/core-dist/src/extension/extensionManager.test.js +598 -0
  231. package/core-dist/src/extension/extensionManager.test.js.map +1 -0
  232. package/core-dist/src/extension/extensionSettings.d.ts +33 -0
  233. package/core-dist/src/extension/extensionSettings.js +186 -0
  234. package/core-dist/src/extension/extensionSettings.js.map +1 -0
  235. package/core-dist/src/extension/extensionSettings.test.d.ts +1 -0
  236. package/core-dist/src/extension/extensionSettings.test.js +488 -0
  237. package/core-dist/src/extension/extensionSettings.test.js.map +1 -0
  238. package/core-dist/src/extension/gemini-converter.d.ts +47 -0
  239. package/core-dist/src/extension/gemini-converter.js +185 -0
  240. package/core-dist/src/extension/gemini-converter.js.map +1 -0
  241. package/core-dist/src/extension/gemini-converter.test.d.ts +6 -0
  242. package/core-dist/src/extension/gemini-converter.test.js +128 -0
  243. package/core-dist/src/extension/gemini-converter.test.js.map +1 -0
  244. package/core-dist/src/extension/github.d.ts +30 -0
  245. package/core-dist/src/extension/github.js +330 -0
  246. package/core-dist/src/extension/github.js.map +1 -0
  247. package/core-dist/src/extension/github.test.d.ts +6 -0
  248. package/core-dist/src/extension/github.test.js +376 -0
  249. package/core-dist/src/extension/github.test.js.map +1 -0
  250. package/core-dist/src/extension/index.d.ts +6 -0
  251. package/core-dist/src/extension/index.js +7 -0
  252. package/core-dist/src/extension/index.js.map +1 -0
  253. package/core-dist/src/extension/marketplace.d.ts +19 -0
  254. package/core-dist/src/extension/marketplace.js +222 -0
  255. package/core-dist/src/extension/marketplace.js.map +1 -0
  256. package/core-dist/src/extension/marketplace.test.d.ts +6 -0
  257. package/core-dist/src/extension/marketplace.test.js +215 -0
  258. package/core-dist/src/extension/marketplace.test.js.map +1 -0
  259. package/core-dist/src/extension/override.d.ts +25 -0
  260. package/core-dist/src/extension/override.js +82 -0
  261. package/core-dist/src/extension/override.js.map +1 -0
  262. package/core-dist/src/extension/override.test.d.ts +6 -0
  263. package/core-dist/src/extension/override.test.js +94 -0
  264. package/core-dist/src/extension/override.test.js.map +1 -0
  265. package/core-dist/src/extension/settings.d.ts +39 -0
  266. package/core-dist/src/extension/settings.js +116 -0
  267. package/core-dist/src/extension/settings.js.map +1 -0
  268. package/core-dist/src/extension/settings.test.d.ts +6 -0
  269. package/core-dist/src/extension/settings.test.js +125 -0
  270. package/core-dist/src/extension/settings.test.js.map +1 -0
  271. package/core-dist/src/extension/storage.d.ts +9 -0
  272. package/core-dist/src/extension/storage.js +38 -0
  273. package/core-dist/src/extension/storage.js.map +1 -0
  274. package/core-dist/src/extension/storage.test.d.ts +6 -0
  275. package/core-dist/src/extension/storage.test.js +64 -0
  276. package/core-dist/src/extension/storage.test.js.map +1 -0
  277. package/core-dist/src/extension/variableSchema.d.ts +40 -0
  278. package/core-dist/src/extension/variableSchema.js +26 -0
  279. package/core-dist/src/extension/variableSchema.js.map +1 -0
  280. package/core-dist/src/extension/variables.d.ts +21 -0
  281. package/core-dist/src/extension/variables.js +46 -0
  282. package/core-dist/src/extension/variables.js.map +1 -0
  283. package/core-dist/src/extension/variables.test.d.ts +6 -0
  284. package/core-dist/src/extension/variables.test.js +17 -0
  285. package/core-dist/src/extension/variables.test.js.map +1 -0
  286. package/core-dist/src/hooks/hookAggregator.d.ts +66 -0
  287. package/core-dist/src/hooks/hookAggregator.js +280 -0
  288. package/core-dist/src/hooks/hookAggregator.js.map +1 -0
  289. package/core-dist/src/hooks/hookAggregator.test.d.ts +6 -0
  290. package/core-dist/src/hooks/hookAggregator.test.js +449 -0
  291. package/core-dist/src/hooks/hookAggregator.test.js.map +1 -0
  292. package/core-dist/src/hooks/hookEventHandler.d.ts +42 -0
  293. package/core-dist/src/hooks/hookEventHandler.js +127 -0
  294. package/core-dist/src/hooks/hookEventHandler.js.map +1 -0
  295. package/core-dist/src/hooks/hookEventHandler.test.d.ts +6 -0
  296. package/core-dist/src/hooks/hookEventHandler.test.js +183 -0
  297. package/core-dist/src/hooks/hookEventHandler.test.js.map +1 -0
  298. package/core-dist/src/hooks/hookPlanner.d.ts +42 -0
  299. package/core-dist/src/hooks/hookPlanner.js +101 -0
  300. package/core-dist/src/hooks/hookPlanner.js.map +1 -0
  301. package/core-dist/src/hooks/hookPlanner.test.d.ts +6 -0
  302. package/core-dist/src/hooks/hookPlanner.test.js +303 -0
  303. package/core-dist/src/hooks/hookPlanner.test.js.map +1 -0
  304. package/core-dist/src/hooks/hookRegistry.d.ts +106 -0
  305. package/core-dist/src/hooks/hookRegistry.js +225 -0
  306. package/core-dist/src/hooks/hookRegistry.js.map +1 -0
  307. package/core-dist/src/hooks/hookRegistry.test.d.ts +6 -0
  308. package/core-dist/src/hooks/hookRegistry.test.js +539 -0
  309. package/core-dist/src/hooks/hookRegistry.test.js.map +1 -0
  310. package/core-dist/src/hooks/hookRunner.d.ts +40 -0
  311. package/core-dist/src/hooks/hookRunner.js +318 -0
  312. package/core-dist/src/hooks/hookRunner.js.map +1 -0
  313. package/core-dist/src/hooks/hookRunner.test.d.ts +6 -0
  314. package/core-dist/src/hooks/hookRunner.test.js +466 -0
  315. package/core-dist/src/hooks/hookRunner.test.js.map +1 -0
  316. package/core-dist/src/hooks/hookSystem.d.ts +43 -0
  317. package/core-dist/src/hooks/hookSystem.js +75 -0
  318. package/core-dist/src/hooks/hookSystem.js.map +1 -0
  319. package/core-dist/src/hooks/hookSystem.test.d.ts +6 -0
  320. package/core-dist/src/hooks/hookSystem.test.js +237 -0
  321. package/core-dist/src/hooks/hookSystem.test.js.map +1 -0
  322. package/core-dist/src/hooks/index.d.ts +16 -0
  323. package/core-dist/src/hooks/index.js +16 -0
  324. package/core-dist/src/hooks/index.js.map +1 -0
  325. package/core-dist/src/hooks/trustedHooks.d.ts +28 -0
  326. package/core-dist/src/hooks/trustedHooks.js +91 -0
  327. package/core-dist/src/hooks/trustedHooks.js.map +1 -0
  328. package/core-dist/src/hooks/types.d.ts +498 -0
  329. package/core-dist/src/hooks/types.js +292 -0
  330. package/core-dist/src/hooks/types.js.map +1 -0
  331. package/core-dist/src/ide/constants.d.ts +9 -0
  332. package/core-dist/src/ide/constants.js +10 -0
  333. package/core-dist/src/ide/constants.js.map +1 -0
  334. package/core-dist/src/ide/detect-ide.d.ts +56 -0
  335. package/core-dist/src/ide/detect-ide.js +68 -0
  336. package/core-dist/src/ide/detect-ide.js.map +1 -0
  337. package/core-dist/src/ide/detect-ide.test.d.ts +6 -0
  338. package/core-dist/src/ide/detect-ide.test.js +113 -0
  339. package/core-dist/src/ide/detect-ide.test.js.map +1 -0
  340. package/core-dist/src/ide/ide-client.d.ts +132 -0
  341. package/core-dist/src/ide/ide-client.js +750 -0
  342. package/core-dist/src/ide/ide-client.js.map +1 -0
  343. package/core-dist/src/ide/ide-client.test.d.ts +6 -0
  344. package/core-dist/src/ide/ide-client.test.js +463 -0
  345. package/core-dist/src/ide/ide-client.test.js.map +1 -0
  346. package/core-dist/src/ide/ide-installer.d.ts +14 -0
  347. package/core-dist/src/ide/ide-installer.js +112 -0
  348. package/core-dist/src/ide/ide-installer.js.map +1 -0
  349. package/core-dist/src/ide/ide-installer.test.d.ts +6 -0
  350. package/core-dist/src/ide/ide-installer.test.js +134 -0
  351. package/core-dist/src/ide/ide-installer.test.js.map +1 -0
  352. package/core-dist/src/ide/ideContext.d.ts +44 -0
  353. package/core-dist/src/ide/ideContext.js +101 -0
  354. package/core-dist/src/ide/ideContext.js.map +1 -0
  355. package/core-dist/src/ide/ideContext.test.d.ts +6 -0
  356. package/core-dist/src/ide/ideContext.test.js +393 -0
  357. package/core-dist/src/ide/ideContext.test.js.map +1 -0
  358. package/core-dist/src/ide/process-utils.d.ts +21 -0
  359. package/core-dist/src/ide/process-utils.js +170 -0
  360. package/core-dist/src/ide/process-utils.js.map +1 -0
  361. package/core-dist/src/ide/process-utils.test.d.ts +6 -0
  362. package/core-dist/src/ide/process-utils.test.js +130 -0
  363. package/core-dist/src/ide/process-utils.test.js.map +1 -0
  364. package/core-dist/src/ide/types.d.ts +486 -0
  365. package/core-dist/src/ide/types.js +138 -0
  366. package/core-dist/src/ide/types.js.map +1 -0
  367. package/core-dist/src/index.d.ts +179 -0
  368. package/core-dist/src/index.js +225 -0
  369. package/core-dist/src/index.js.map +1 -0
  370. package/core-dist/src/index.test.d.ts +6 -0
  371. package/core-dist/src/index.test.js +12 -0
  372. package/core-dist/src/index.test.js.map +1 -0
  373. package/core-dist/src/lsp/LspConfigLoader.d.ts +46 -0
  374. package/core-dist/src/lsp/LspConfigLoader.js +381 -0
  375. package/core-dist/src/lsp/LspConfigLoader.js.map +1 -0
  376. package/core-dist/src/lsp/LspConfigLoader.test.d.ts +6 -0
  377. package/core-dist/src/lsp/LspConfigLoader.test.js +80 -0
  378. package/core-dist/src/lsp/LspConfigLoader.test.js.map +1 -0
  379. package/core-dist/src/lsp/LspConnectionFactory.d.ts +62 -0
  380. package/core-dist/src/lsp/LspConnectionFactory.js +305 -0
  381. package/core-dist/src/lsp/LspConnectionFactory.js.map +1 -0
  382. package/core-dist/src/lsp/LspLanguageDetector.d.ts +39 -0
  383. package/core-dist/src/lsp/LspLanguageDetector.js +199 -0
  384. package/core-dist/src/lsp/LspLanguageDetector.js.map +1 -0
  385. package/core-dist/src/lsp/LspResponseNormalizer.d.ts +122 -0
  386. package/core-dist/src/lsp/LspResponseNormalizer.js +710 -0
  387. package/core-dist/src/lsp/LspResponseNormalizer.js.map +1 -0
  388. package/core-dist/src/lsp/LspServerManager.d.ts +87 -0
  389. package/core-dist/src/lsp/LspServerManager.js +563 -0
  390. package/core-dist/src/lsp/LspServerManager.js.map +1 -0
  391. package/core-dist/src/lsp/NativeLspClient.d.ts +149 -0
  392. package/core-dist/src/lsp/NativeLspClient.js +169 -0
  393. package/core-dist/src/lsp/NativeLspClient.js.map +1 -0
  394. package/core-dist/src/lsp/NativeLspService.d.ts +106 -0
  395. package/core-dist/src/lsp/NativeLspService.integration.test.d.ts +6 -0
  396. package/core-dist/src/lsp/NativeLspService.integration.test.js +663 -0
  397. package/core-dist/src/lsp/NativeLspService.integration.test.js.map +1 -0
  398. package/core-dist/src/lsp/NativeLspService.js +623 -0
  399. package/core-dist/src/lsp/NativeLspService.js.map +1 -0
  400. package/core-dist/src/lsp/NativeLspService.test.d.ts +6 -0
  401. package/core-dist/src/lsp/NativeLspService.test.js +99 -0
  402. package/core-dist/src/lsp/NativeLspService.test.js.map +1 -0
  403. package/core-dist/src/lsp/constants.d.ts +35 -0
  404. package/core-dist/src/lsp/constants.js +86 -0
  405. package/core-dist/src/lsp/constants.js.map +1 -0
  406. package/core-dist/src/lsp/types.d.ts +409 -0
  407. package/core-dist/src/lsp/types.js +7 -0
  408. package/core-dist/src/lsp/types.js.map +1 -0
  409. package/core-dist/src/mcp/constants.d.ts +22 -0
  410. package/core-dist/src/mcp/constants.js +23 -0
  411. package/core-dist/src/mcp/constants.js.map +1 -0
  412. package/core-dist/src/mcp/google-auth-provider.d.ts +23 -0
  413. package/core-dist/src/mcp/google-auth-provider.js +75 -0
  414. package/core-dist/src/mcp/google-auth-provider.js.map +1 -0
  415. package/core-dist/src/mcp/google-auth-provider.test.d.ts +6 -0
  416. package/core-dist/src/mcp/google-auth-provider.test.js +89 -0
  417. package/core-dist/src/mcp/google-auth-provider.test.js.map +1 -0
  418. package/core-dist/src/mcp/oauth-provider.d.ts +150 -0
  419. package/core-dist/src/mcp/oauth-provider.js +617 -0
  420. package/core-dist/src/mcp/oauth-provider.js.map +1 -0
  421. package/core-dist/src/mcp/oauth-provider.test.d.ts +6 -0
  422. package/core-dist/src/mcp/oauth-provider.test.js +917 -0
  423. package/core-dist/src/mcp/oauth-provider.test.js.map +1 -0
  424. package/core-dist/src/mcp/oauth-token-storage.d.ts +65 -0
  425. package/core-dist/src/mcp/oauth-token-storage.js +182 -0
  426. package/core-dist/src/mcp/oauth-token-storage.js.map +1 -0
  427. package/core-dist/src/mcp/oauth-token-storage.test.d.ts +6 -0
  428. package/core-dist/src/mcp/oauth-token-storage.test.js +307 -0
  429. package/core-dist/src/mcp/oauth-token-storage.test.js.map +1 -0
  430. package/core-dist/src/mcp/oauth-utils.d.ts +124 -0
  431. package/core-dist/src/mcp/oauth-utils.js +252 -0
  432. package/core-dist/src/mcp/oauth-utils.js.map +1 -0
  433. package/core-dist/src/mcp/oauth-utils.test.d.ts +6 -0
  434. package/core-dist/src/mcp/oauth-utils.test.js +220 -0
  435. package/core-dist/src/mcp/oauth-utils.test.js.map +1 -0
  436. package/core-dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
  437. package/core-dist/src/mcp/sa-impersonation-provider.js +133 -0
  438. package/core-dist/src/mcp/sa-impersonation-provider.js.map +1 -0
  439. package/core-dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
  440. package/core-dist/src/mcp/sa-impersonation-provider.test.js +117 -0
  441. package/core-dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
  442. package/core-dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
  443. package/core-dist/src/mcp/token-storage/base-token-storage.js +36 -0
  444. package/core-dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
  445. package/core-dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
  446. package/core-dist/src/mcp/token-storage/base-token-storage.test.js +160 -0
  447. package/core-dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
  448. package/core-dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
  449. package/core-dist/src/mcp/token-storage/file-token-storage.js +144 -0
  450. package/core-dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
  451. package/core-dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
  452. package/core-dist/src/mcp/token-storage/file-token-storage.test.js +235 -0
  453. package/core-dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
  454. package/core-dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
  455. package/core-dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
  456. package/core-dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
  457. package/core-dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
  458. package/core-dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
  459. package/core-dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
  460. package/core-dist/src/mcp/token-storage/index.d.ts +11 -0
  461. package/core-dist/src/mcp/token-storage/index.js +12 -0
  462. package/core-dist/src/mcp/token-storage/index.js.map +1 -0
  463. package/core-dist/src/mcp/token-storage/keychain-token-storage.d.ts +35 -0
  464. package/core-dist/src/mcp/token-storage/keychain-token-storage.js +248 -0
  465. package/core-dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
  466. package/core-dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
  467. package/core-dist/src/mcp/token-storage/keychain-token-storage.test.js +254 -0
  468. package/core-dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
  469. package/core-dist/src/mcp/token-storage/types.d.ts +38 -0
  470. package/core-dist/src/mcp/token-storage/types.js +11 -0
  471. package/core-dist/src/mcp/token-storage/types.js.map +1 -0
  472. package/core-dist/src/mocks/msw.d.ts +6 -0
  473. package/core-dist/src/mocks/msw.js +8 -0
  474. package/core-dist/src/mocks/msw.js.map +1 -0
  475. package/core-dist/src/models/constants.d.ts +71 -0
  476. package/core-dist/src/models/constants.js +92 -0
  477. package/core-dist/src/models/constants.js.map +1 -0
  478. package/core-dist/src/models/index.d.ts +10 -0
  479. package/core-dist/src/models/index.js +12 -0
  480. package/core-dist/src/models/index.js.map +1 -0
  481. package/core-dist/src/models/modelConfigErrors.d.ts +46 -0
  482. package/core-dist/src/models/modelConfigErrors.js +87 -0
  483. package/core-dist/src/models/modelConfigErrors.js.map +1 -0
  484. package/core-dist/src/models/modelConfigResolver.d.ts +84 -0
  485. package/core-dist/src/models/modelConfigResolver.js +204 -0
  486. package/core-dist/src/models/modelConfigResolver.js.map +1 -0
  487. package/core-dist/src/models/modelConfigResolver.test.d.ts +6 -0
  488. package/core-dist/src/models/modelConfigResolver.test.js +302 -0
  489. package/core-dist/src/models/modelConfigResolver.test.js.map +1 -0
  490. package/core-dist/src/models/modelRegistry.d.ts +55 -0
  491. package/core-dist/src/models/modelRegistry.js +182 -0
  492. package/core-dist/src/models/modelRegistry.js.map +1 -0
  493. package/core-dist/src/models/modelRegistry.test.d.ts +6 -0
  494. package/core-dist/src/models/modelRegistry.test.js +408 -0
  495. package/core-dist/src/models/modelRegistry.test.js.map +1 -0
  496. package/core-dist/src/models/modelsConfig.d.ts +343 -0
  497. package/core-dist/src/models/modelsConfig.js +957 -0
  498. package/core-dist/src/models/modelsConfig.js.map +1 -0
  499. package/core-dist/src/models/modelsConfig.test.d.ts +6 -0
  500. package/core-dist/src/models/modelsConfig.test.js +1242 -0
  501. package/core-dist/src/models/modelsConfig.test.js.map +1 -0
  502. package/core-dist/src/models/types.d.ts +114 -0
  503. package/core-dist/src/models/types.js +7 -0
  504. package/core-dist/src/models/types.js.map +1 -0
  505. package/core-dist/src/output/json-formatter.d.ts +11 -0
  506. package/core-dist/src/output/json-formatter.js +30 -0
  507. package/core-dist/src/output/json-formatter.js.map +1 -0
  508. package/core-dist/src/output/json-formatter.test.d.ts +6 -0
  509. package/core-dist/src/output/json-formatter.test.js +266 -0
  510. package/core-dist/src/output/json-formatter.test.js.map +1 -0
  511. package/core-dist/src/output/types.d.ts +25 -0
  512. package/core-dist/src/output/types.js +17 -0
  513. package/core-dist/src/output/types.js.map +1 -0
  514. package/core-dist/src/prompts/mcp-prompts.d.ts +8 -0
  515. package/core-dist/src/prompts/mcp-prompts.js +13 -0
  516. package/core-dist/src/prompts/mcp-prompts.js.map +1 -0
  517. package/core-dist/src/prompts/prompt-registry.d.ts +34 -0
  518. package/core-dist/src/prompts/prompt-registry.js +65 -0
  519. package/core-dist/src/prompts/prompt-registry.js.map +1 -0
  520. package/core-dist/src/qwen/qwenContentGenerator.d.ts +71 -0
  521. package/core-dist/src/qwen/qwenContentGenerator.js +182 -0
  522. package/core-dist/src/qwen/qwenContentGenerator.js.map +1 -0
  523. package/core-dist/src/qwen/qwenContentGenerator.test.d.ts +6 -0
  524. package/core-dist/src/qwen/qwenContentGenerator.test.js +1175 -0
  525. package/core-dist/src/qwen/qwenContentGenerator.test.js.map +1 -0
  526. package/core-dist/src/qwen/qwenOAuth2.d.ts +195 -0
  527. package/core-dist/src/qwen/qwenOAuth2.js +677 -0
  528. package/core-dist/src/qwen/qwenOAuth2.js.map +1 -0
  529. package/core-dist/src/qwen/qwenOAuth2.test.d.ts +6 -0
  530. package/core-dist/src/qwen/qwenOAuth2.test.js +1621 -0
  531. package/core-dist/src/qwen/qwenOAuth2.test.js.map +1 -0
  532. package/core-dist/src/qwen/sharedTokenManager.d.ts +196 -0
  533. package/core-dist/src/qwen/sharedTokenManager.js +649 -0
  534. package/core-dist/src/qwen/sharedTokenManager.js.map +1 -0
  535. package/core-dist/src/qwen/sharedTokenManager.test.d.ts +7 -0
  536. package/core-dist/src/qwen/sharedTokenManager.test.js +662 -0
  537. package/core-dist/src/qwen/sharedTokenManager.test.js.map +1 -0
  538. package/core-dist/src/services/chatCompressionService.d.ts +32 -0
  539. package/core-dist/src/services/chatCompressionService.js +213 -0
  540. package/core-dist/src/services/chatCompressionService.js.map +1 -0
  541. package/core-dist/src/services/chatCompressionService.test.d.ts +6 -0
  542. package/core-dist/src/services/chatCompressionService.test.js +343 -0
  543. package/core-dist/src/services/chatCompressionService.test.js.map +1 -0
  544. package/core-dist/src/services/chatRecordingService.d.ts +215 -0
  545. package/core-dist/src/services/chatRecordingService.js +285 -0
  546. package/core-dist/src/services/chatRecordingService.js.map +1 -0
  547. package/core-dist/src/services/chatRecordingService.test.d.ts +6 -0
  548. package/core-dist/src/services/chatRecordingService.test.js +299 -0
  549. package/core-dist/src/services/chatRecordingService.test.js.map +1 -0
  550. package/core-dist/src/services/fileDiscoveryService.d.ts +45 -0
  551. package/core-dist/src/services/fileDiscoveryService.js +104 -0
  552. package/core-dist/src/services/fileDiscoveryService.js.map +1 -0
  553. package/core-dist/src/services/fileDiscoveryService.test.d.ts +6 -0
  554. package/core-dist/src/services/fileDiscoveryService.test.js +143 -0
  555. package/core-dist/src/services/fileDiscoveryService.test.js.map +1 -0
  556. package/core-dist/src/services/fileSystemService.d.ts +88 -0
  557. package/core-dist/src/services/fileSystemService.js +131 -0
  558. package/core-dist/src/services/fileSystemService.js.map +1 -0
  559. package/core-dist/src/services/fileSystemService.test.d.ts +6 -0
  560. package/core-dist/src/services/fileSystemService.test.js +216 -0
  561. package/core-dist/src/services/fileSystemService.test.js.map +1 -0
  562. package/core-dist/src/services/gitService.d.ts +22 -0
  563. package/core-dist/src/services/gitService.js +98 -0
  564. package/core-dist/src/services/gitService.js.map +1 -0
  565. package/core-dist/src/services/gitService.test.d.ts +6 -0
  566. package/core-dist/src/services/gitService.test.js +187 -0
  567. package/core-dist/src/services/gitService.test.js.map +1 -0
  568. package/core-dist/src/services/loopDetectionService.d.ts +86 -0
  569. package/core-dist/src/services/loopDetectionService.js +239 -0
  570. package/core-dist/src/services/loopDetectionService.js.map +1 -0
  571. package/core-dist/src/services/loopDetectionService.test.d.ts +6 -0
  572. package/core-dist/src/services/loopDetectionService.test.js +478 -0
  573. package/core-dist/src/services/loopDetectionService.test.js.map +1 -0
  574. package/core-dist/src/services/sessionService.d.ts +200 -0
  575. package/core-dist/src/services/sessionService.js +527 -0
  576. package/core-dist/src/services/sessionService.js.map +1 -0
  577. package/core-dist/src/services/sessionService.test.d.ts +6 -0
  578. package/core-dist/src/services/sessionService.test.js +576 -0
  579. package/core-dist/src/services/sessionService.test.js.map +1 -0
  580. package/core-dist/src/services/shellExecutionService.d.ts +104 -0
  581. package/core-dist/src/services/shellExecutionService.js +626 -0
  582. package/core-dist/src/services/shellExecutionService.js.map +1 -0
  583. package/core-dist/src/services/shellExecutionService.test.d.ts +6 -0
  584. package/core-dist/src/services/shellExecutionService.test.js +684 -0
  585. package/core-dist/src/services/shellExecutionService.test.js.map +1 -0
  586. package/core-dist/src/skills/index.d.ts +19 -0
  587. package/core-dist/src/skills/index.js +9 -0
  588. package/core-dist/src/skills/index.js.map +1 -0
  589. package/core-dist/src/skills/skill-load.d.ts +4 -0
  590. package/core-dist/src/skills/skill-load.js +137 -0
  591. package/core-dist/src/skills/skill-load.js.map +1 -0
  592. package/core-dist/src/skills/skill-load.test.d.ts +6 -0
  593. package/core-dist/src/skills/skill-load.test.js +237 -0
  594. package/core-dist/src/skills/skill-load.test.js.map +1 -0
  595. package/core-dist/src/skills/skill-manager.d.ts +134 -0
  596. package/core-dist/src/skills/skill-manager.js +505 -0
  597. package/core-dist/src/skills/skill-manager.js.map +1 -0
  598. package/core-dist/src/skills/skill-manager.test.d.ts +6 -0
  599. package/core-dist/src/skills/skill-manager.test.js +527 -0
  600. package/core-dist/src/skills/skill-manager.test.js.map +1 -0
  601. package/core-dist/src/skills/types.d.ts +88 -0
  602. package/core-dist/src/skills/types.js +29 -0
  603. package/core-dist/src/skills/types.js.map +1 -0
  604. package/core-dist/src/subagents/builtin-agents.d.ts +35 -0
  605. package/core-dist/src/subagents/builtin-agents.js +85 -0
  606. package/core-dist/src/subagents/builtin-agents.js.map +1 -0
  607. package/core-dist/src/subagents/builtin-agents.test.d.ts +6 -0
  608. package/core-dist/src/subagents/builtin-agents.test.js +78 -0
  609. package/core-dist/src/subagents/builtin-agents.test.js.map +1 -0
  610. package/core-dist/src/subagents/index.d.ts +29 -0
  611. package/core-dist/src/subagents/index.js +15 -0
  612. package/core-dist/src/subagents/index.js.map +1 -0
  613. package/core-dist/src/subagents/subagent-events.d.ts +105 -0
  614. package/core-dist/src/subagents/subagent-events.js +32 -0
  615. package/core-dist/src/subagents/subagent-events.js.map +1 -0
  616. package/core-dist/src/subagents/subagent-hooks.d.ts +29 -0
  617. package/core-dist/src/subagents/subagent-hooks.js +7 -0
  618. package/core-dist/src/subagents/subagent-hooks.js.map +1 -0
  619. package/core-dist/src/subagents/subagent-manager.d.ts +178 -0
  620. package/core-dist/src/subagents/subagent-manager.js +711 -0
  621. package/core-dist/src/subagents/subagent-manager.js.map +1 -0
  622. package/core-dist/src/subagents/subagent-manager.test.d.ts +6 -0
  623. package/core-dist/src/subagents/subagent-manager.test.js +829 -0
  624. package/core-dist/src/subagents/subagent-manager.test.js.map +1 -0
  625. package/core-dist/src/subagents/subagent-statistics.d.ts +50 -0
  626. package/core-dist/src/subagents/subagent-statistics.js +210 -0
  627. package/core-dist/src/subagents/subagent-statistics.js.map +1 -0
  628. package/core-dist/src/subagents/subagent-statistics.test.d.ts +6 -0
  629. package/core-dist/src/subagents/subagent-statistics.test.js +238 -0
  630. package/core-dist/src/subagents/subagent-statistics.test.js.map +1 -0
  631. package/core-dist/src/subagents/subagent.d.ts +167 -0
  632. package/core-dist/src/subagents/subagent.js +758 -0
  633. package/core-dist/src/subagents/subagent.js.map +1 -0
  634. package/core-dist/src/subagents/subagent.test.d.ts +6 -0
  635. package/core-dist/src/subagents/subagent.test.js +819 -0
  636. package/core-dist/src/subagents/subagent.test.js.map +1 -0
  637. package/core-dist/src/subagents/types.d.ts +224 -0
  638. package/core-dist/src/subagents/types.js +58 -0
  639. package/core-dist/src/subagents/types.js.map +1 -0
  640. package/core-dist/src/subagents/types.test.d.ts +6 -0
  641. package/core-dist/src/subagents/types.test.js +31 -0
  642. package/core-dist/src/subagents/types.test.js.map +1 -0
  643. package/core-dist/src/subagents/validation.d.ts +63 -0
  644. package/core-dist/src/subagents/validation.js +293 -0
  645. package/core-dist/src/subagents/validation.js.map +1 -0
  646. package/core-dist/src/subagents/validation.test.d.ts +6 -0
  647. package/core-dist/src/subagents/validation.test.js +330 -0
  648. package/core-dist/src/subagents/validation.test.js.map +1 -0
  649. package/core-dist/src/telemetry/config.d.ts +31 -0
  650. package/core-dist/src/telemetry/config.js +74 -0
  651. package/core-dist/src/telemetry/config.js.map +1 -0
  652. package/core-dist/src/telemetry/config.test.d.ts +6 -0
  653. package/core-dist/src/telemetry/config.test.js +124 -0
  654. package/core-dist/src/telemetry/config.test.js.map +1 -0
  655. package/core-dist/src/telemetry/constants.d.ts +39 -0
  656. package/core-dist/src/telemetry/constants.js +41 -0
  657. package/core-dist/src/telemetry/constants.js.map +1 -0
  658. package/core-dist/src/telemetry/file-exporters.d.ts +29 -0
  659. package/core-dist/src/telemetry/file-exporters.js +62 -0
  660. package/core-dist/src/telemetry/file-exporters.js.map +1 -0
  661. package/core-dist/src/telemetry/index.d.ts +25 -0
  662. package/core-dist/src/telemetry/index.js +31 -0
  663. package/core-dist/src/telemetry/index.js.map +1 -0
  664. package/core-dist/src/telemetry/integration.test.circular.d.ts +6 -0
  665. package/core-dist/src/telemetry/integration.test.circular.js +95 -0
  666. package/core-dist/src/telemetry/integration.test.circular.js.map +1 -0
  667. package/core-dist/src/telemetry/loggers.d.ts +40 -0
  668. package/core-dist/src/telemetry/loggers.js +712 -0
  669. package/core-dist/src/telemetry/loggers.js.map +1 -0
  670. package/core-dist/src/telemetry/loggers.test.circular.d.ts +6 -0
  671. package/core-dist/src/telemetry/loggers.test.circular.js +107 -0
  672. package/core-dist/src/telemetry/loggers.test.circular.js.map +1 -0
  673. package/core-dist/src/telemetry/loggers.test.d.ts +6 -0
  674. package/core-dist/src/telemetry/loggers.test.js +961 -0
  675. package/core-dist/src/telemetry/loggers.test.js.map +1 -0
  676. package/core-dist/src/telemetry/metrics.d.ts +320 -0
  677. package/core-dist/src/telemetry/metrics.js +532 -0
  678. package/core-dist/src/telemetry/metrics.js.map +1 -0
  679. package/core-dist/src/telemetry/metrics.test.d.ts +6 -0
  680. package/core-dist/src/telemetry/metrics.test.js +746 -0
  681. package/core-dist/src/telemetry/metrics.test.js.map +1 -0
  682. package/core-dist/src/telemetry/qwen-logger/event-types.d.ts +89 -0
  683. package/core-dist/src/telemetry/qwen-logger/event-types.js +2 -0
  684. package/core-dist/src/telemetry/qwen-logger/event-types.js.map +1 -0
  685. package/core-dist/src/telemetry/qwen-logger/qwen-logger.d.ts +102 -0
  686. package/core-dist/src/telemetry/qwen-logger/qwen-logger.js +739 -0
  687. package/core-dist/src/telemetry/qwen-logger/qwen-logger.js.map +1 -0
  688. package/core-dist/src/telemetry/qwen-logger/qwen-logger.test.d.ts +6 -0
  689. package/core-dist/src/telemetry/qwen-logger/qwen-logger.test.js +380 -0
  690. package/core-dist/src/telemetry/qwen-logger/qwen-logger.test.js.map +1 -0
  691. package/core-dist/src/telemetry/sdk.d.ts +9 -0
  692. package/core-dist/src/telemetry/sdk.js +163 -0
  693. package/core-dist/src/telemetry/sdk.js.map +1 -0
  694. package/core-dist/src/telemetry/sdk.test.d.ts +6 -0
  695. package/core-dist/src/telemetry/sdk.test.js +116 -0
  696. package/core-dist/src/telemetry/sdk.test.js.map +1 -0
  697. package/core-dist/src/telemetry/telemetry-utils.d.ts +6 -0
  698. package/core-dist/src/telemetry/telemetry-utils.js +14 -0
  699. package/core-dist/src/telemetry/telemetry-utils.js.map +1 -0
  700. package/core-dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
  701. package/core-dist/src/telemetry/telemetry-utils.test.js +40 -0
  702. package/core-dist/src/telemetry/telemetry-utils.test.js.map +1 -0
  703. package/core-dist/src/telemetry/telemetry.test.d.ts +6 -0
  704. package/core-dist/src/telemetry/telemetry.test.js +49 -0
  705. package/core-dist/src/telemetry/telemetry.test.js.map +1 -0
  706. package/core-dist/src/telemetry/tool-call-decision.d.ts +13 -0
  707. package/core-dist/src/telemetry/tool-call-decision.js +29 -0
  708. package/core-dist/src/telemetry/tool-call-decision.js.map +1 -0
  709. package/core-dist/src/telemetry/types.d.ts +363 -0
  710. package/core-dist/src/telemetry/types.js +635 -0
  711. package/core-dist/src/telemetry/types.js.map +1 -0
  712. package/core-dist/src/telemetry/uiTelemetry.d.ts +80 -0
  713. package/core-dist/src/telemetry/uiTelemetry.js +164 -0
  714. package/core-dist/src/telemetry/uiTelemetry.js.map +1 -0
  715. package/core-dist/src/telemetry/uiTelemetry.test.d.ts +6 -0
  716. package/core-dist/src/telemetry/uiTelemetry.test.js +625 -0
  717. package/core-dist/src/telemetry/uiTelemetry.test.js.map +1 -0
  718. package/core-dist/src/test-utils/config.d.ts +17 -0
  719. package/core-dist/src/test-utils/config.js +31 -0
  720. package/core-dist/src/test-utils/config.js.map +1 -0
  721. package/core-dist/src/test-utils/index.d.ts +6 -0
  722. package/core-dist/src/test-utils/index.js +7 -0
  723. package/core-dist/src/test-utils/index.js.map +1 -0
  724. package/core-dist/src/test-utils/mock-tool.d.ts +66 -0
  725. package/core-dist/src/test-utils/mock-tool.js +121 -0
  726. package/core-dist/src/test-utils/mock-tool.js.map +1 -0
  727. package/core-dist/src/test-utils/mockWorkspaceContext.d.ts +13 -0
  728. package/core-dist/src/test-utils/mockWorkspaceContext.js +24 -0
  729. package/core-dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
  730. package/core-dist/src/tools/askUserQuestion.d.ts +41 -0
  731. package/core-dist/src/tools/askUserQuestion.js +247 -0
  732. package/core-dist/src/tools/askUserQuestion.js.map +1 -0
  733. package/core-dist/src/tools/askUserQuestion.test.d.ts +6 -0
  734. package/core-dist/src/tools/askUserQuestion.test.js +218 -0
  735. package/core-dist/src/tools/askUserQuestion.test.js.map +1 -0
  736. package/core-dist/src/tools/diffOptions.d.ts +9 -0
  737. package/core-dist/src/tools/diffOptions.js +46 -0
  738. package/core-dist/src/tools/diffOptions.js.map +1 -0
  739. package/core-dist/src/tools/diffOptions.test.d.ts +6 -0
  740. package/core-dist/src/tools/diffOptions.test.js +155 -0
  741. package/core-dist/src/tools/diffOptions.test.js.map +1 -0
  742. package/core-dist/src/tools/edit.d.ts +55 -0
  743. package/core-dist/src/tools/edit.js +446 -0
  744. package/core-dist/src/tools/edit.js.map +1 -0
  745. package/core-dist/src/tools/edit.test.d.ts +6 -0
  746. package/core-dist/src/tools/edit.test.js +742 -0
  747. package/core-dist/src/tools/edit.test.js.map +1 -0
  748. package/core-dist/src/tools/exitPlanMode.d.ts +28 -0
  749. package/core-dist/src/tools/exitPlanMode.js +144 -0
  750. package/core-dist/src/tools/exitPlanMode.js.map +1 -0
  751. package/core-dist/src/tools/exitPlanMode.test.d.ts +6 -0
  752. package/core-dist/src/tools/exitPlanMode.test.js +178 -0
  753. package/core-dist/src/tools/exitPlanMode.test.js.map +1 -0
  754. package/core-dist/src/tools/glob.d.ts +44 -0
  755. package/core-dist/src/tools/glob.js +195 -0
  756. package/core-dist/src/tools/glob.js.map +1 -0
  757. package/core-dist/src/tools/glob.test.d.ts +6 -0
  758. package/core-dist/src/tools/glob.test.js +481 -0
  759. package/core-dist/src/tools/glob.test.js.map +1 -0
  760. package/core-dist/src/tools/grep.d.ts +44 -0
  761. package/core-dist/src/tools/grep.js +427 -0
  762. package/core-dist/src/tools/grep.js.map +1 -0
  763. package/core-dist/src/tools/grep.test.d.ts +6 -0
  764. package/core-dist/src/tools/grep.test.js +360 -0
  765. package/core-dist/src/tools/grep.test.js.map +1 -0
  766. package/core-dist/src/tools/ls.d.ts +68 -0
  767. package/core-dist/src/tools/ls.js +221 -0
  768. package/core-dist/src/tools/ls.js.map +1 -0
  769. package/core-dist/src/tools/ls.test.d.ts +6 -0
  770. package/core-dist/src/tools/ls.test.js +246 -0
  771. package/core-dist/src/tools/ls.test.js.map +1 -0
  772. package/core-dist/src/tools/lsp.d.ts +66 -0
  773. package/core-dist/src/tools/lsp.js +894 -0
  774. package/core-dist/src/tools/lsp.js.map +1 -0
  775. package/core-dist/src/tools/lsp.test.d.ts +6 -0
  776. package/core-dist/src/tools/lsp.test.js +960 -0
  777. package/core-dist/src/tools/lsp.test.js.map +1 -0
  778. package/core-dist/src/tools/mcp-client-manager.d.ts +110 -0
  779. package/core-dist/src/tools/mcp-client-manager.js +381 -0
  780. package/core-dist/src/tools/mcp-client-manager.js.map +1 -0
  781. package/core-dist/src/tools/mcp-client-manager.test.d.ts +6 -0
  782. package/core-dist/src/tools/mcp-client-manager.test.js +207 -0
  783. package/core-dist/src/tools/mcp-client-manager.test.js.map +1 -0
  784. package/core-dist/src/tools/mcp-client.d.ts +199 -0
  785. package/core-dist/src/tools/mcp-client.js +1001 -0
  786. package/core-dist/src/tools/mcp-client.js.map +1 -0
  787. package/core-dist/src/tools/mcp-client.test.d.ts +6 -0
  788. package/core-dist/src/tools/mcp-client.test.js +307 -0
  789. package/core-dist/src/tools/mcp-client.test.js.map +1 -0
  790. package/core-dist/src/tools/mcp-tool.d.ts +69 -0
  791. package/core-dist/src/tools/mcp-tool.js +365 -0
  792. package/core-dist/src/tools/mcp-tool.js.map +1 -0
  793. package/core-dist/src/tools/mcp-tool.test.d.ts +6 -0
  794. package/core-dist/src/tools/mcp-tool.test.js +827 -0
  795. package/core-dist/src/tools/mcp-tool.test.js.map +1 -0
  796. package/core-dist/src/tools/memoryTool.d.ts +42 -0
  797. package/core-dist/src/tools/memoryTool.js +403 -0
  798. package/core-dist/src/tools/memoryTool.js.map +1 -0
  799. package/core-dist/src/tools/memoryTool.test.d.ts +6 -0
  800. package/core-dist/src/tools/memoryTool.test.js +416 -0
  801. package/core-dist/src/tools/memoryTool.test.js.map +1 -0
  802. package/core-dist/src/tools/modifiable-tool.d.ts +32 -0
  803. package/core-dist/src/tools/modifiable-tool.js +90 -0
  804. package/core-dist/src/tools/modifiable-tool.js.map +1 -0
  805. package/core-dist/src/tools/modifiable-tool.test.d.ts +6 -0
  806. package/core-dist/src/tools/modifiable-tool.test.js +188 -0
  807. package/core-dist/src/tools/modifiable-tool.test.js.map +1 -0
  808. package/core-dist/src/tools/read-file.d.ts +35 -0
  809. package/core-dist/src/tools/read-file.js +141 -0
  810. package/core-dist/src/tools/read-file.js.map +1 -0
  811. package/core-dist/src/tools/read-file.test.d.ts +6 -0
  812. package/core-dist/src/tools/read-file.test.js +333 -0
  813. package/core-dist/src/tools/read-file.test.js.map +1 -0
  814. package/core-dist/src/tools/ripGrep.d.ts +44 -0
  815. package/core-dist/src/tools/ripGrep.js +235 -0
  816. package/core-dist/src/tools/ripGrep.js.map +1 -0
  817. package/core-dist/src/tools/ripGrep.test.d.ts +6 -0
  818. package/core-dist/src/tools/ripGrep.test.js +529 -0
  819. package/core-dist/src/tools/ripGrep.test.js.map +1 -0
  820. package/core-dist/src/tools/sdk-control-client-transport.d.ts +67 -0
  821. package/core-dist/src/tools/sdk-control-client-transport.js +93 -0
  822. package/core-dist/src/tools/sdk-control-client-transport.js.map +1 -0
  823. package/core-dist/src/tools/shell.d.ts +34 -0
  824. package/core-dist/src/tools/shell.js +509 -0
  825. package/core-dist/src/tools/shell.js.map +1 -0
  826. package/core-dist/src/tools/shell.test.d.ts +6 -0
  827. package/core-dist/src/tools/shell.test.js +880 -0
  828. package/core-dist/src/tools/shell.test.js.map +1 -0
  829. package/core-dist/src/tools/skill.d.ts +45 -0
  830. package/core-dist/src/tools/skill.js +214 -0
  831. package/core-dist/src/tools/skill.js.map +1 -0
  832. package/core-dist/src/tools/skill.test.d.ts +6 -0
  833. package/core-dist/src/tools/skill.test.js +280 -0
  834. package/core-dist/src/tools/skill.test.js.map +1 -0
  835. package/core-dist/src/tools/task.d.ts +60 -0
  836. package/core-dist/src/tools/task.js +417 -0
  837. package/core-dist/src/tools/task.js.map +1 -0
  838. package/core-dist/src/tools/task.test.d.ts +6 -0
  839. package/core-dist/src/tools/task.test.js +367 -0
  840. package/core-dist/src/tools/task.test.js.map +1 -0
  841. package/core-dist/src/tools/todoWrite.d.ts +42 -0
  842. package/core-dist/src/tools/todoWrite.js +409 -0
  843. package/core-dist/src/tools/todoWrite.js.map +1 -0
  844. package/core-dist/src/tools/todoWrite.test.d.ts +6 -0
  845. package/core-dist/src/tools/todoWrite.test.js +234 -0
  846. package/core-dist/src/tools/todoWrite.test.js.map +1 -0
  847. package/core-dist/src/tools/tool-error.d.ts +45 -0
  848. package/core-dist/src/tools/tool-error.js +61 -0
  849. package/core-dist/src/tools/tool-error.js.map +1 -0
  850. package/core-dist/src/tools/tool-names.d.ts +60 -0
  851. package/core-dist/src/tools/tool-names.js +66 -0
  852. package/core-dist/src/tools/tool-names.js.map +1 -0
  853. package/core-dist/src/tools/tool-registry.d.ts +103 -0
  854. package/core-dist/src/tools/tool-registry.js +404 -0
  855. package/core-dist/src/tools/tool-registry.js.map +1 -0
  856. package/core-dist/src/tools/tool-registry.test.d.ts +6 -0
  857. package/core-dist/src/tools/tool-registry.test.js +331 -0
  858. package/core-dist/src/tools/tool-registry.test.js.map +1 -0
  859. package/core-dist/src/tools/tools.d.ts +364 -0
  860. package/core-dist/src/tools/tools.js +263 -0
  861. package/core-dist/src/tools/tools.js.map +1 -0
  862. package/core-dist/src/tools/tools.test.d.ts +6 -0
  863. package/core-dist/src/tools/tools.test.js +205 -0
  864. package/core-dist/src/tools/tools.test.js.map +1 -0
  865. package/core-dist/src/tools/web-fetch.d.ts +31 -0
  866. package/core-dist/src/tools/web-fetch.js +168 -0
  867. package/core-dist/src/tools/web-fetch.js.map +1 -0
  868. package/core-dist/src/tools/web-fetch.test.d.ts +6 -0
  869. package/core-dist/src/tools/web-fetch.test.js +134 -0
  870. package/core-dist/src/tools/web-fetch.test.js.map +1 -0
  871. package/core-dist/src/tools/web-search/base-provider.d.ts +31 -0
  872. package/core-dist/src/tools/web-search/base-provider.js +34 -0
  873. package/core-dist/src/tools/web-search/base-provider.js.map +1 -0
  874. package/core-dist/src/tools/web-search/index.d.ts +24 -0
  875. package/core-dist/src/tools/web-search/index.js +249 -0
  876. package/core-dist/src/tools/web-search/index.js.map +1 -0
  877. package/core-dist/src/tools/web-search/index.test.d.ts +6 -0
  878. package/core-dist/src/tools/web-search/index.test.js +237 -0
  879. package/core-dist/src/tools/web-search/index.test.js.map +1 -0
  880. package/core-dist/src/tools/web-search/providers/dashscope-provider.d.ts +23 -0
  881. package/core-dist/src/tools/web-search/providers/dashscope-provider.js +120 -0
  882. package/core-dist/src/tools/web-search/providers/dashscope-provider.js.map +1 -0
  883. package/core-dist/src/tools/web-search/providers/google-provider.d.ts +17 -0
  884. package/core-dist/src/tools/web-search/providers/google-provider.js +55 -0
  885. package/core-dist/src/tools/web-search/providers/google-provider.js.map +1 -0
  886. package/core-dist/src/tools/web-search/providers/tavily-provider.d.ts +17 -0
  887. package/core-dist/src/tools/web-search/providers/tavily-provider.js +54 -0
  888. package/core-dist/src/tools/web-search/providers/tavily-provider.js.map +1 -0
  889. package/core-dist/src/tools/web-search/types.d.ts +138 -0
  890. package/core-dist/src/tools/web-search/types.js +7 -0
  891. package/core-dist/src/tools/web-search/types.js.map +1 -0
  892. package/core-dist/src/tools/web-search/utils.d.ts +28 -0
  893. package/core-dist/src/tools/web-search/utils.js +35 -0
  894. package/core-dist/src/tools/web-search/utils.js.map +1 -0
  895. package/core-dist/src/tools/write-file.d.ts +52 -0
  896. package/core-dist/src/tools/write-file.js +316 -0
  897. package/core-dist/src/tools/write-file.js.map +1 -0
  898. package/core-dist/src/tools/write-file.test.d.ts +6 -0
  899. package/core-dist/src/tools/write-file.test.js +613 -0
  900. package/core-dist/src/tools/write-file.test.js.map +1 -0
  901. package/core-dist/src/utils/LruCache.d.ts +13 -0
  902. package/core-dist/src/utils/LruCache.js +38 -0
  903. package/core-dist/src/utils/LruCache.js.map +1 -0
  904. package/core-dist/src/utils/browser.d.ts +13 -0
  905. package/core-dist/src/utils/browser.js +50 -0
  906. package/core-dist/src/utils/browser.js.map +1 -0
  907. package/core-dist/src/utils/configResolver.d.ts +120 -0
  908. package/core-dist/src/utils/configResolver.js +125 -0
  909. package/core-dist/src/utils/configResolver.js.map +1 -0
  910. package/core-dist/src/utils/configResolver.test.d.ts +6 -0
  911. package/core-dist/src/utils/configResolver.test.js +99 -0
  912. package/core-dist/src/utils/configResolver.test.js.map +1 -0
  913. package/core-dist/src/utils/debugLogger.d.ts +46 -0
  914. package/core-dist/src/utils/debugLogger.js +159 -0
  915. package/core-dist/src/utils/debugLogger.js.map +1 -0
  916. package/core-dist/src/utils/debugLogger.test.d.ts +6 -0
  917. package/core-dist/src/utils/debugLogger.test.js +188 -0
  918. package/core-dist/src/utils/debugLogger.test.js.map +1 -0
  919. package/core-dist/src/utils/editHelper.d.ts +58 -0
  920. package/core-dist/src/utils/editHelper.js +342 -0
  921. package/core-dist/src/utils/editHelper.js.map +1 -0
  922. package/core-dist/src/utils/editHelper.test.d.ts +6 -0
  923. package/core-dist/src/utils/editHelper.test.js +127 -0
  924. package/core-dist/src/utils/editHelper.test.js.map +1 -0
  925. package/core-dist/src/utils/editor.d.ts +37 -0
  926. package/core-dist/src/utils/editor.js +179 -0
  927. package/core-dist/src/utils/editor.js.map +1 -0
  928. package/core-dist/src/utils/editor.test.d.ts +6 -0
  929. package/core-dist/src/utils/editor.test.js +434 -0
  930. package/core-dist/src/utils/editor.test.js.map +1 -0
  931. package/core-dist/src/utils/envVarResolver.d.ts +39 -0
  932. package/core-dist/src/utils/envVarResolver.js +100 -0
  933. package/core-dist/src/utils/envVarResolver.js.map +1 -0
  934. package/core-dist/src/utils/envVarResolver.test.d.ts +6 -0
  935. package/core-dist/src/utils/envVarResolver.test.js +221 -0
  936. package/core-dist/src/utils/envVarResolver.test.js.map +1 -0
  937. package/core-dist/src/utils/environmentContext.d.ts +21 -0
  938. package/core-dist/src/utils/environmentContext.js +73 -0
  939. package/core-dist/src/utils/environmentContext.js.map +1 -0
  940. package/core-dist/src/utils/environmentContext.test.d.ts +6 -0
  941. package/core-dist/src/utils/environmentContext.test.js +151 -0
  942. package/core-dist/src/utils/environmentContext.test.js.map +1 -0
  943. package/core-dist/src/utils/errorParsing.d.ts +7 -0
  944. package/core-dist/src/utils/errorParsing.js +72 -0
  945. package/core-dist/src/utils/errorParsing.js.map +1 -0
  946. package/core-dist/src/utils/errorParsing.test.d.ts +6 -0
  947. package/core-dist/src/utils/errorParsing.test.js +87 -0
  948. package/core-dist/src/utils/errorParsing.test.js.map +1 -0
  949. package/core-dist/src/utils/errorReporting.d.ts +14 -0
  950. package/core-dist/src/utils/errorReporting.js +56 -0
  951. package/core-dist/src/utils/errorReporting.js.map +1 -0
  952. package/core-dist/src/utils/errorReporting.test.d.ts +6 -0
  953. package/core-dist/src/utils/errorReporting.test.js +84 -0
  954. package/core-dist/src/utils/errorReporting.test.js.map +1 -0
  955. package/core-dist/src/utils/errors.d.ts +44 -0
  956. package/core-dist/src/utils/errors.js +114 -0
  957. package/core-dist/src/utils/errors.js.map +1 -0
  958. package/core-dist/src/utils/errors.test.d.ts +6 -0
  959. package/core-dist/src/utils/errors.test.js +70 -0
  960. package/core-dist/src/utils/errors.test.js.map +1 -0
  961. package/core-dist/src/utils/fetch.d.ts +14 -0
  962. package/core-dist/src/utils/fetch.js +152 -0
  963. package/core-dist/src/utils/fetch.js.map +1 -0
  964. package/core-dist/src/utils/fetch.test.d.ts +6 -0
  965. package/core-dist/src/utils/fetch.test.js +40 -0
  966. package/core-dist/src/utils/fetch.test.js.map +1 -0
  967. package/core-dist/src/utils/fileUtils.d.ts +102 -0
  968. package/core-dist/src/utils/fileUtils.js +584 -0
  969. package/core-dist/src/utils/fileUtils.js.map +1 -0
  970. package/core-dist/src/utils/fileUtils.test.d.ts +6 -0
  971. package/core-dist/src/utils/fileUtils.test.js +808 -0
  972. package/core-dist/src/utils/fileUtils.test.js.map +1 -0
  973. package/core-dist/src/utils/filesearch/crawlCache.d.ts +25 -0
  974. package/core-dist/src/utils/filesearch/crawlCache.js +57 -0
  975. package/core-dist/src/utils/filesearch/crawlCache.js.map +1 -0
  976. package/core-dist/src/utils/filesearch/crawlCache.test.d.ts +6 -0
  977. package/core-dist/src/utils/filesearch/crawlCache.test.js +103 -0
  978. package/core-dist/src/utils/filesearch/crawlCache.test.js.map +1 -0
  979. package/core-dist/src/utils/filesearch/crawler.d.ts +15 -0
  980. package/core-dist/src/utils/filesearch/crawler.js +50 -0
  981. package/core-dist/src/utils/filesearch/crawler.js.map +1 -0
  982. package/core-dist/src/utils/filesearch/crawler.test.d.ts +6 -0
  983. package/core-dist/src/utils/filesearch/crawler.test.js +468 -0
  984. package/core-dist/src/utils/filesearch/crawler.test.js.map +1 -0
  985. package/core-dist/src/utils/filesearch/fileSearch.d.ts +38 -0
  986. package/core-dist/src/utils/filesearch/fileSearch.js +194 -0
  987. package/core-dist/src/utils/filesearch/fileSearch.js.map +1 -0
  988. package/core-dist/src/utils/filesearch/fileSearch.test.d.ts +6 -0
  989. package/core-dist/src/utils/filesearch/fileSearch.test.js +642 -0
  990. package/core-dist/src/utils/filesearch/fileSearch.test.js.map +1 -0
  991. package/core-dist/src/utils/filesearch/ignore.d.ts +42 -0
  992. package/core-dist/src/utils/filesearch/ignore.js +106 -0
  993. package/core-dist/src/utils/filesearch/ignore.js.map +1 -0
  994. package/core-dist/src/utils/filesearch/ignore.test.d.ts +6 -0
  995. package/core-dist/src/utils/filesearch/ignore.test.js +144 -0
  996. package/core-dist/src/utils/filesearch/ignore.test.js.map +1 -0
  997. package/core-dist/src/utils/filesearch/result-cache.d.ts +33 -0
  998. package/core-dist/src/utils/filesearch/result-cache.js +59 -0
  999. package/core-dist/src/utils/filesearch/result-cache.js.map +1 -0
  1000. package/core-dist/src/utils/filesearch/result-cache.test.d.ts +6 -0
  1001. package/core-dist/src/utils/filesearch/result-cache.test.js +46 -0
  1002. package/core-dist/src/utils/filesearch/result-cache.test.js.map +1 -0
  1003. package/core-dist/src/utils/formatters.d.ts +6 -0
  1004. package/core-dist/src/utils/formatters.js +16 -0
  1005. package/core-dist/src/utils/formatters.js.map +1 -0
  1006. package/core-dist/src/utils/generateContentResponseUtilities.d.ts +13 -0
  1007. package/core-dist/src/utils/generateContentResponseUtilities.js +95 -0
  1008. package/core-dist/src/utils/generateContentResponseUtilities.js.map +1 -0
  1009. package/core-dist/src/utils/generateContentResponseUtilities.test.d.ts +6 -0
  1010. package/core-dist/src/utils/generateContentResponseUtilities.test.js +235 -0
  1011. package/core-dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
  1012. package/core-dist/src/utils/getFolderStructure.d.ts +31 -0
  1013. package/core-dist/src/utils/getFolderStructure.js +233 -0
  1014. package/core-dist/src/utils/getFolderStructure.js.map +1 -0
  1015. package/core-dist/src/utils/getFolderStructure.test.d.ts +6 -0
  1016. package/core-dist/src/utils/getFolderStructure.test.js +282 -0
  1017. package/core-dist/src/utils/getFolderStructure.test.js.map +1 -0
  1018. package/core-dist/src/utils/getPty.d.ts +7 -0
  1019. package/core-dist/src/utils/getPty.js +7 -0
  1020. package/core-dist/src/utils/getPty.js.map +1 -0
  1021. package/core-dist/src/utils/gitIgnoreParser.d.ts +16 -0
  1022. package/core-dist/src/utils/gitIgnoreParser.js +152 -0
  1023. package/core-dist/src/utils/gitIgnoreParser.js.map +1 -0
  1024. package/core-dist/src/utils/gitIgnoreParser.test.d.ts +6 -0
  1025. package/core-dist/src/utils/gitIgnoreParser.test.js +185 -0
  1026. package/core-dist/src/utils/gitIgnoreParser.test.js.map +1 -0
  1027. package/core-dist/src/utils/gitUtils.d.ts +21 -0
  1028. package/core-dist/src/utils/gitUtils.js +78 -0
  1029. package/core-dist/src/utils/gitUtils.js.map +1 -0
  1030. package/core-dist/src/utils/iconvHelper.d.ts +33 -0
  1031. package/core-dist/src/utils/iconvHelper.js +48 -0
  1032. package/core-dist/src/utils/iconvHelper.js.map +1 -0
  1033. package/core-dist/src/utils/ignorePatterns.d.ts +103 -0
  1034. package/core-dist/src/utils/ignorePatterns.js +222 -0
  1035. package/core-dist/src/utils/ignorePatterns.js.map +1 -0
  1036. package/core-dist/src/utils/ignorePatterns.test.d.ts +6 -0
  1037. package/core-dist/src/utils/ignorePatterns.test.js +255 -0
  1038. package/core-dist/src/utils/ignorePatterns.test.js.map +1 -0
  1039. package/core-dist/src/utils/installationManager.d.ts +16 -0
  1040. package/core-dist/src/utils/installationManager.js +52 -0
  1041. package/core-dist/src/utils/installationManager.js.map +1 -0
  1042. package/core-dist/src/utils/installationManager.test.d.ts +6 -0
  1043. package/core-dist/src/utils/installationManager.test.js +79 -0
  1044. package/core-dist/src/utils/installationManager.test.js.map +1 -0
  1045. package/core-dist/src/utils/jsonl-utils.d.ts +38 -0
  1046. package/core-dist/src/utils/jsonl-utils.js +176 -0
  1047. package/core-dist/src/utils/jsonl-utils.js.map +1 -0
  1048. package/core-dist/src/utils/language-detection.d.ts +6 -0
  1049. package/core-dist/src/utils/language-detection.js +101 -0
  1050. package/core-dist/src/utils/language-detection.js.map +1 -0
  1051. package/core-dist/src/utils/memoryDiscovery.d.ts +15 -0
  1052. package/core-dist/src/utils/memoryDiscovery.js +238 -0
  1053. package/core-dist/src/utils/memoryDiscovery.js.map +1 -0
  1054. package/core-dist/src/utils/memoryDiscovery.test.d.ts +6 -0
  1055. package/core-dist/src/utils/memoryDiscovery.test.js +212 -0
  1056. package/core-dist/src/utils/memoryDiscovery.test.js.map +1 -0
  1057. package/core-dist/src/utils/memoryImportProcessor.d.ts +41 -0
  1058. package/core-dist/src/utils/memoryImportProcessor.js +296 -0
  1059. package/core-dist/src/utils/memoryImportProcessor.js.map +1 -0
  1060. package/core-dist/src/utils/memoryImportProcessor.test.d.ts +6 -0
  1061. package/core-dist/src/utils/memoryImportProcessor.test.js +631 -0
  1062. package/core-dist/src/utils/memoryImportProcessor.test.js.map +1 -0
  1063. package/core-dist/src/utils/messageInspectors.d.ts +8 -0
  1064. package/core-dist/src/utils/messageInspectors.js +16 -0
  1065. package/core-dist/src/utils/messageInspectors.js.map +1 -0
  1066. package/core-dist/src/utils/nextSpeakerChecker.d.ts +12 -0
  1067. package/core-dist/src/utils/nextSpeakerChecker.js +99 -0
  1068. package/core-dist/src/utils/nextSpeakerChecker.js.map +1 -0
  1069. package/core-dist/src/utils/nextSpeakerChecker.test.d.ts +6 -0
  1070. package/core-dist/src/utils/nextSpeakerChecker.test.js +183 -0
  1071. package/core-dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
  1072. package/core-dist/src/utils/openaiLogger.d.ts +42 -0
  1073. package/core-dist/src/utils/openaiLogger.js +140 -0
  1074. package/core-dist/src/utils/openaiLogger.js.map +1 -0
  1075. package/core-dist/src/utils/openaiLogger.test.d.ts +6 -0
  1076. package/core-dist/src/utils/openaiLogger.test.js +314 -0
  1077. package/core-dist/src/utils/openaiLogger.test.js.map +1 -0
  1078. package/core-dist/src/utils/partUtils.d.ts +35 -0
  1079. package/core-dist/src/utils/partUtils.js +133 -0
  1080. package/core-dist/src/utils/partUtils.js.map +1 -0
  1081. package/core-dist/src/utils/partUtils.test.d.ts +6 -0
  1082. package/core-dist/src/utils/partUtils.test.js +241 -0
  1083. package/core-dist/src/utils/partUtils.test.js.map +1 -0
  1084. package/core-dist/src/utils/pathReader.d.ts +17 -0
  1085. package/core-dist/src/utils/pathReader.js +92 -0
  1086. package/core-dist/src/utils/pathReader.js.map +1 -0
  1087. package/core-dist/src/utils/pathReader.test.d.ts +6 -0
  1088. package/core-dist/src/utils/pathReader.test.js +367 -0
  1089. package/core-dist/src/utils/pathReader.test.js.map +1 -0
  1090. package/core-dist/src/utils/paths.d.ts +110 -0
  1091. package/core-dist/src/utils/paths.js +269 -0
  1092. package/core-dist/src/utils/paths.js.map +1 -0
  1093. package/core-dist/src/utils/paths.test.d.ts +6 -0
  1094. package/core-dist/src/utils/paths.test.js +633 -0
  1095. package/core-dist/src/utils/paths.test.js.map +1 -0
  1096. package/core-dist/src/utils/projectSummary.d.ts +22 -0
  1097. package/core-dist/src/utils/projectSummary.js +86 -0
  1098. package/core-dist/src/utils/projectSummary.js.map +1 -0
  1099. package/core-dist/src/utils/promptIdContext.d.ts +7 -0
  1100. package/core-dist/src/utils/promptIdContext.js +8 -0
  1101. package/core-dist/src/utils/promptIdContext.js.map +1 -0
  1102. package/core-dist/src/utils/quotaErrorDetection.d.ts +19 -0
  1103. package/core-dist/src/utils/quotaErrorDetection.js +84 -0
  1104. package/core-dist/src/utils/quotaErrorDetection.js.map +1 -0
  1105. package/core-dist/src/utils/quotaErrorDetection.test.d.ts +6 -0
  1106. package/core-dist/src/utils/quotaErrorDetection.test.js +104 -0
  1107. package/core-dist/src/utils/quotaErrorDetection.test.js.map +1 -0
  1108. package/core-dist/src/utils/qwenIgnoreParser.d.ts +18 -0
  1109. package/core-dist/src/utils/qwenIgnoreParser.js +61 -0
  1110. package/core-dist/src/utils/qwenIgnoreParser.js.map +1 -0
  1111. package/core-dist/src/utils/qwenIgnoreParser.test.d.ts +6 -0
  1112. package/core-dist/src/utils/qwenIgnoreParser.test.js +50 -0
  1113. package/core-dist/src/utils/qwenIgnoreParser.test.js.map +1 -0
  1114. package/core-dist/src/utils/rateLimit.d.ts +23 -0
  1115. package/core-dist/src/utils/rateLimit.js +69 -0
  1116. package/core-dist/src/utils/rateLimit.js.map +1 -0
  1117. package/core-dist/src/utils/rateLimit.test.d.ts +6 -0
  1118. package/core-dist/src/utils/rateLimit.test.js +72 -0
  1119. package/core-dist/src/utils/rateLimit.test.js.map +1 -0
  1120. package/core-dist/src/utils/readManyFiles.d.ts +67 -0
  1121. package/core-dist/src/utils/readManyFiles.js +133 -0
  1122. package/core-dist/src/utils/readManyFiles.js.map +1 -0
  1123. package/core-dist/src/utils/readManyFiles.test.d.ts +6 -0
  1124. package/core-dist/src/utils/readManyFiles.test.js +230 -0
  1125. package/core-dist/src/utils/readManyFiles.test.js.map +1 -0
  1126. package/core-dist/src/utils/request-tokenizer/imageTokenizer.d.ts +112 -0
  1127. package/core-dist/src/utils/request-tokenizer/imageTokenizer.js +403 -0
  1128. package/core-dist/src/utils/request-tokenizer/imageTokenizer.js.map +1 -0
  1129. package/core-dist/src/utils/request-tokenizer/imageTokenizer.test.d.ts +6 -0
  1130. package/core-dist/src/utils/request-tokenizer/imageTokenizer.test.js +114 -0
  1131. package/core-dist/src/utils/request-tokenizer/imageTokenizer.test.js.map +1 -0
  1132. package/core-dist/src/utils/request-tokenizer/index.d.ts +9 -0
  1133. package/core-dist/src/utils/request-tokenizer/index.js +9 -0
  1134. package/core-dist/src/utils/request-tokenizer/index.js.map +1 -0
  1135. package/core-dist/src/utils/request-tokenizer/requestTokenizer.d.ts +52 -0
  1136. package/core-dist/src/utils/request-tokenizer/requestTokenizer.js +252 -0
  1137. package/core-dist/src/utils/request-tokenizer/requestTokenizer.js.map +1 -0
  1138. package/core-dist/src/utils/request-tokenizer/requestTokenizer.test.d.ts +6 -0
  1139. package/core-dist/src/utils/request-tokenizer/requestTokenizer.test.js +227 -0
  1140. package/core-dist/src/utils/request-tokenizer/requestTokenizer.test.js.map +1 -0
  1141. package/core-dist/src/utils/request-tokenizer/supportedImageFormats.d.ts +30 -0
  1142. package/core-dist/src/utils/request-tokenizer/supportedImageFormats.js +41 -0
  1143. package/core-dist/src/utils/request-tokenizer/supportedImageFormats.js.map +1 -0
  1144. package/core-dist/src/utils/request-tokenizer/textTokenizer.d.ts +32 -0
  1145. package/core-dist/src/utils/request-tokenizer/textTokenizer.js +54 -0
  1146. package/core-dist/src/utils/request-tokenizer/textTokenizer.js.map +1 -0
  1147. package/core-dist/src/utils/request-tokenizer/textTokenizer.test.d.ts +6 -0
  1148. package/core-dist/src/utils/request-tokenizer/textTokenizer.test.js +237 -0
  1149. package/core-dist/src/utils/request-tokenizer/textTokenizer.test.js.map +1 -0
  1150. package/core-dist/src/utils/request-tokenizer/types.d.ts +34 -0
  1151. package/core-dist/src/utils/request-tokenizer/types.js +7 -0
  1152. package/core-dist/src/utils/request-tokenizer/types.js.map +1 -0
  1153. package/core-dist/src/utils/retry.d.ts +38 -0
  1154. package/core-dist/src/utils/retry.js +180 -0
  1155. package/core-dist/src/utils/retry.js.map +1 -0
  1156. package/core-dist/src/utils/retry.test.d.ts +6 -0
  1157. package/core-dist/src/utils/retry.test.js +402 -0
  1158. package/core-dist/src/utils/retry.test.js.map +1 -0
  1159. package/core-dist/src/utils/ripgrepUtils.d.ts +61 -0
  1160. package/core-dist/src/utils/ripgrepUtils.js +227 -0
  1161. package/core-dist/src/utils/ripgrepUtils.js.map +1 -0
  1162. package/core-dist/src/utils/ripgrepUtils.test.d.ts +6 -0
  1163. package/core-dist/src/utils/ripgrepUtils.test.js +101 -0
  1164. package/core-dist/src/utils/ripgrepUtils.test.js.map +1 -0
  1165. package/core-dist/src/utils/runtimeFetchOptions.d.ts +44 -0
  1166. package/core-dist/src/utils/runtimeFetchOptions.js +92 -0
  1167. package/core-dist/src/utils/runtimeFetchOptions.js.map +1 -0
  1168. package/core-dist/src/utils/runtimeFetchOptions.test.d.ts +6 -0
  1169. package/core-dist/src/utils/runtimeFetchOptions.test.js +70 -0
  1170. package/core-dist/src/utils/runtimeFetchOptions.test.js.map +1 -0
  1171. package/core-dist/src/utils/safeJsonParse.d.ts +15 -0
  1172. package/core-dist/src/utils/safeJsonParse.js +43 -0
  1173. package/core-dist/src/utils/safeJsonParse.js.map +1 -0
  1174. package/core-dist/src/utils/safeJsonParse.test.d.ts +6 -0
  1175. package/core-dist/src/utils/safeJsonParse.test.js +112 -0
  1176. package/core-dist/src/utils/safeJsonParse.test.js.map +1 -0
  1177. package/core-dist/src/utils/safeJsonStringify.d.ts +13 -0
  1178. package/core-dist/src/utils/safeJsonStringify.js +25 -0
  1179. package/core-dist/src/utils/safeJsonStringify.js.map +1 -0
  1180. package/core-dist/src/utils/safeJsonStringify.test.d.ts +6 -0
  1181. package/core-dist/src/utils/safeJsonStringify.test.js +61 -0
  1182. package/core-dist/src/utils/safeJsonStringify.test.js.map +1 -0
  1183. package/core-dist/src/utils/schemaConverter.d.ts +15 -0
  1184. package/core-dist/src/utils/schemaConverter.js +109 -0
  1185. package/core-dist/src/utils/schemaConverter.js.map +1 -0
  1186. package/core-dist/src/utils/schemaConverter.test.d.ts +6 -0
  1187. package/core-dist/src/utils/schemaConverter.test.js +106 -0
  1188. package/core-dist/src/utils/schemaConverter.test.js.map +1 -0
  1189. package/core-dist/src/utils/schemaValidator.d.ts +16 -0
  1190. package/core-dist/src/utils/schemaValidator.js +123 -0
  1191. package/core-dist/src/utils/schemaValidator.js.map +1 -0
  1192. package/core-dist/src/utils/schemaValidator.test.d.ts +6 -0
  1193. package/core-dist/src/utils/schemaValidator.test.js +266 -0
  1194. package/core-dist/src/utils/schemaValidator.test.js.map +1 -0
  1195. package/core-dist/src/utils/secure-browser-launcher.d.ts +23 -0
  1196. package/core-dist/src/utils/secure-browser-launcher.js +165 -0
  1197. package/core-dist/src/utils/secure-browser-launcher.js.map +1 -0
  1198. package/core-dist/src/utils/secure-browser-launcher.test.d.ts +6 -0
  1199. package/core-dist/src/utils/secure-browser-launcher.test.js +149 -0
  1200. package/core-dist/src/utils/secure-browser-launcher.test.js.map +1 -0
  1201. package/core-dist/src/utils/shell-utils.d.ts +158 -0
  1202. package/core-dist/src/utils/shell-utils.js +739 -0
  1203. package/core-dist/src/utils/shell-utils.js.map +1 -0
  1204. package/core-dist/src/utils/shell-utils.test.d.ts +6 -0
  1205. package/core-dist/src/utils/shell-utils.test.js +466 -0
  1206. package/core-dist/src/utils/shell-utils.test.js.map +1 -0
  1207. package/core-dist/src/utils/shellReadOnlyChecker.d.ts +6 -0
  1208. package/core-dist/src/utils/shellReadOnlyChecker.js +290 -0
  1209. package/core-dist/src/utils/shellReadOnlyChecker.js.map +1 -0
  1210. package/core-dist/src/utils/shellReadOnlyChecker.test.d.ts +6 -0
  1211. package/core-dist/src/utils/shellReadOnlyChecker.test.js +157 -0
  1212. package/core-dist/src/utils/shellReadOnlyChecker.test.js.map +1 -0
  1213. package/core-dist/src/utils/subagentGenerator.d.ts +20 -0
  1214. package/core-dist/src/utils/subagentGenerator.js +120 -0
  1215. package/core-dist/src/utils/subagentGenerator.js.map +1 -0
  1216. package/core-dist/src/utils/subagentGenerator.test.d.ts +6 -0
  1217. package/core-dist/src/utils/subagentGenerator.test.js +135 -0
  1218. package/core-dist/src/utils/subagentGenerator.test.js.map +1 -0
  1219. package/core-dist/src/utils/summarizer.d.ts +25 -0
  1220. package/core-dist/src/utils/summarizer.js +53 -0
  1221. package/core-dist/src/utils/summarizer.js.map +1 -0
  1222. package/core-dist/src/utils/summarizer.test.d.ts +6 -0
  1223. package/core-dist/src/utils/summarizer.test.js +128 -0
  1224. package/core-dist/src/utils/summarizer.test.js.map +1 -0
  1225. package/core-dist/src/utils/symlink.d.ts +26 -0
  1226. package/core-dist/src/utils/symlink.js +43 -0
  1227. package/core-dist/src/utils/symlink.js.map +1 -0
  1228. package/core-dist/src/utils/systemEncoding.d.ts +40 -0
  1229. package/core-dist/src/utils/systemEncoding.js +160 -0
  1230. package/core-dist/src/utils/systemEncoding.js.map +1 -0
  1231. package/core-dist/src/utils/systemEncoding.test.d.ts +6 -0
  1232. package/core-dist/src/utils/systemEncoding.test.js +367 -0
  1233. package/core-dist/src/utils/systemEncoding.test.js.map +1 -0
  1234. package/core-dist/src/utils/terminalSerializer.d.ts +25 -0
  1235. package/core-dist/src/utils/terminalSerializer.js +432 -0
  1236. package/core-dist/src/utils/terminalSerializer.js.map +1 -0
  1237. package/core-dist/src/utils/terminalSerializer.test.d.ts +6 -0
  1238. package/core-dist/src/utils/terminalSerializer.test.js +176 -0
  1239. package/core-dist/src/utils/terminalSerializer.test.js.map +1 -0
  1240. package/core-dist/src/utils/testUtils.d.ts +29 -0
  1241. package/core-dist/src/utils/testUtils.js +70 -0
  1242. package/core-dist/src/utils/testUtils.js.map +1 -0
  1243. package/core-dist/src/utils/textUtils.d.ts +29 -0
  1244. package/core-dist/src/utils/textUtils.js +59 -0
  1245. package/core-dist/src/utils/textUtils.js.map +1 -0
  1246. package/core-dist/src/utils/textUtils.test.d.ts +6 -0
  1247. package/core-dist/src/utils/textUtils.test.js +91 -0
  1248. package/core-dist/src/utils/textUtils.test.js.map +1 -0
  1249. package/core-dist/src/utils/thoughtUtils.d.ts +23 -0
  1250. package/core-dist/src/utils/thoughtUtils.js +53 -0
  1251. package/core-dist/src/utils/thoughtUtils.js.map +1 -0
  1252. package/core-dist/src/utils/thoughtUtils.test.d.ts +6 -0
  1253. package/core-dist/src/utils/thoughtUtils.test.js +78 -0
  1254. package/core-dist/src/utils/thoughtUtils.test.js.map +1 -0
  1255. package/core-dist/src/utils/toml-to-markdown-converter.d.ts +22 -0
  1256. package/core-dist/src/utils/toml-to-markdown-converter.js +61 -0
  1257. package/core-dist/src/utils/toml-to-markdown-converter.js.map +1 -0
  1258. package/core-dist/src/utils/toml-to-markdown-converter.test.d.ts +6 -0
  1259. package/core-dist/src/utils/toml-to-markdown-converter.test.js +73 -0
  1260. package/core-dist/src/utils/toml-to-markdown-converter.test.js.map +1 -0
  1261. package/core-dist/src/utils/tool-utils.d.ts +22 -0
  1262. package/core-dist/src/utils/tool-utils.js +121 -0
  1263. package/core-dist/src/utils/tool-utils.js.map +1 -0
  1264. package/core-dist/src/utils/tool-utils.test.d.ts +6 -0
  1265. package/core-dist/src/utils/tool-utils.test.js +100 -0
  1266. package/core-dist/src/utils/tool-utils.test.js.map +1 -0
  1267. package/core-dist/src/utils/workspaceContext.d.ts +66 -0
  1268. package/core-dist/src/utils/workspaceContext.js +173 -0
  1269. package/core-dist/src/utils/workspaceContext.js.map +1 -0
  1270. package/core-dist/src/utils/workspaceContext.test.d.ts +6 -0
  1271. package/core-dist/src/utils/workspaceContext.test.js +313 -0
  1272. package/core-dist/src/utils/workspaceContext.test.js.map +1 -0
  1273. package/core-dist/src/utils/yaml-parser.d.ts +29 -0
  1274. package/core-dist/src/utils/yaml-parser.js +172 -0
  1275. package/core-dist/src/utils/yaml-parser.js.map +1 -0
  1276. package/core-dist/src/utils/yaml-parser.test.d.ts +6 -0
  1277. package/core-dist/src/utils/yaml-parser.test.js +170 -0
  1278. package/core-dist/src/utils/yaml-parser.test.js.map +1 -0
  1279. package/core-dist/tsconfig.tsbuildinfo +1 -0
  1280. package/package.json +3 -1
  1281. package/scripts/postinstall.cjs +102 -203
@@ -0,0 +1,2221 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
7
+ import { ApprovalMode, BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES, DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD, SkillTool, } from '../index.js';
8
+ import { CoreToolScheduler, convertToFunctionResponse, truncateAndSaveToFile, } from './coreToolScheduler.js';
9
+ import { MockModifiableTool, MockTool, MOCK_TOOL_SHOULD_CONFIRM_EXECUTE, } from '../test-utils/mock-tool.js';
10
+ import * as fs from 'node:fs/promises';
11
+ import * as path from 'node:path';
12
+ vi.mock('fs/promises', () => ({
13
+ writeFile: vi.fn(),
14
+ }));
15
+ class TestApprovalTool extends BaseDeclarativeTool {
16
+ config;
17
+ static Name = 'testApprovalTool';
18
+ constructor(config) {
19
+ super(TestApprovalTool.Name, 'TestApprovalTool', 'A tool for testing approval logic', Kind.Edit, {
20
+ properties: { id: { type: 'string' } },
21
+ required: ['id'],
22
+ type: 'object',
23
+ });
24
+ this.config = config;
25
+ }
26
+ createInvocation(params) {
27
+ return new TestApprovalInvocation(this.config, params);
28
+ }
29
+ }
30
+ class TestApprovalInvocation extends BaseToolInvocation {
31
+ config;
32
+ constructor(config, params) {
33
+ super(params);
34
+ this.config = config;
35
+ }
36
+ getDescription() {
37
+ return `Test tool ${this.params.id}`;
38
+ }
39
+ async shouldConfirmExecute() {
40
+ // Need confirmation unless approval mode is AUTO_EDIT
41
+ if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
42
+ return false;
43
+ }
44
+ return {
45
+ type: 'edit',
46
+ title: `Confirm Test Tool ${this.params.id}`,
47
+ fileName: `test-${this.params.id}.txt`,
48
+ filePath: `/test-${this.params.id}.txt`,
49
+ fileDiff: 'Test diff content',
50
+ originalContent: '',
51
+ newContent: 'Test content',
52
+ onConfirm: async (outcome) => {
53
+ if (outcome === ToolConfirmationOutcome.ProceedAlways) {
54
+ this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
55
+ }
56
+ },
57
+ };
58
+ }
59
+ async execute() {
60
+ return {
61
+ llmContent: `Executed test tool ${this.params.id}`,
62
+ returnDisplay: `Executed test tool ${this.params.id}`,
63
+ };
64
+ }
65
+ }
66
+ class AbortDuringConfirmationInvocation extends BaseToolInvocation {
67
+ abortController;
68
+ abortError;
69
+ constructor(abortController, abortError, params) {
70
+ super(params);
71
+ this.abortController = abortController;
72
+ this.abortError = abortError;
73
+ }
74
+ async shouldConfirmExecute(_signal) {
75
+ this.abortController.abort();
76
+ throw this.abortError;
77
+ }
78
+ async execute(_abortSignal) {
79
+ throw new Error('execute should not be called when confirmation fails');
80
+ }
81
+ getDescription() {
82
+ return 'Abort during confirmation invocation';
83
+ }
84
+ }
85
+ class AbortDuringConfirmationTool extends BaseDeclarativeTool {
86
+ abortController;
87
+ abortError;
88
+ constructor(abortController, abortError) {
89
+ super('abortDuringConfirmationTool', 'Abort During Confirmation Tool', 'A tool that aborts while confirming execution.', Kind.Other, {
90
+ type: 'object',
91
+ properties: {},
92
+ });
93
+ this.abortController = abortController;
94
+ this.abortError = abortError;
95
+ }
96
+ createInvocation(params) {
97
+ return new AbortDuringConfirmationInvocation(this.abortController, this.abortError, params);
98
+ }
99
+ }
100
+ async function waitForStatus(onToolCallsUpdate, status, timeout = 5000) {
101
+ return new Promise((resolve, reject) => {
102
+ const startTime = Date.now();
103
+ const check = () => {
104
+ if (Date.now() - startTime > timeout) {
105
+ const seenStatuses = onToolCallsUpdate.mock.calls
106
+ .flatMap((call) => call[0])
107
+ .map((toolCall) => toolCall.status);
108
+ reject(new Error(`Timed out waiting for status "${status}". Seen statuses: ${seenStatuses.join(', ')}`));
109
+ return;
110
+ }
111
+ const foundCall = onToolCallsUpdate.mock.calls
112
+ .flatMap((call) => call[0])
113
+ .find((toolCall) => toolCall.status === status);
114
+ if (foundCall) {
115
+ resolve(foundCall);
116
+ }
117
+ else {
118
+ setTimeout(check, 10); // Check again in 10ms
119
+ }
120
+ };
121
+ check();
122
+ });
123
+ }
124
+ describe('CoreToolScheduler', () => {
125
+ it('should cancel a tool call if the signal is aborted before confirmation', async () => {
126
+ const mockTool = new MockTool({
127
+ name: 'mockTool',
128
+ shouldConfirmExecute: MOCK_TOOL_SHOULD_CONFIRM_EXECUTE,
129
+ });
130
+ const declarativeTool = mockTool;
131
+ const mockToolRegistry = {
132
+ getTool: () => declarativeTool,
133
+ getFunctionDeclarations: () => [],
134
+ tools: new Map(),
135
+ discovery: {},
136
+ registerTool: () => { },
137
+ getToolByName: () => declarativeTool,
138
+ getToolByDisplayName: () => declarativeTool,
139
+ getTools: () => [],
140
+ discoverTools: async () => { },
141
+ getAllTools: () => [],
142
+ getToolsByServer: () => [],
143
+ };
144
+ const onAllToolCallsComplete = vi.fn();
145
+ const onToolCallsUpdate = vi.fn();
146
+ const mockConfig = {
147
+ getSessionId: () => 'test-session-id',
148
+ getUsageStatisticsEnabled: () => true,
149
+ getDebugMode: () => false,
150
+ getApprovalMode: () => ApprovalMode.DEFAULT,
151
+ getAllowedTools: () => [],
152
+ getContentGeneratorConfig: () => ({
153
+ model: 'test-model',
154
+ authType: 'gemini',
155
+ }),
156
+ getShellExecutionConfig: () => ({
157
+ terminalWidth: 90,
158
+ terminalHeight: 30,
159
+ }),
160
+ storage: {
161
+ getProjectTempDir: () => '/tmp',
162
+ },
163
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
164
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
165
+ getToolRegistry: () => mockToolRegistry,
166
+ getUseModelRouter: () => false,
167
+ getGeminiClient: () => null, // No client needed for these tests
168
+ getChatRecordingService: () => undefined,
169
+ };
170
+ const scheduler = new CoreToolScheduler({
171
+ config: mockConfig,
172
+ onAllToolCallsComplete,
173
+ onToolCallsUpdate,
174
+ getPreferredEditor: () => 'vscode',
175
+ onEditorClose: vi.fn(),
176
+ });
177
+ const abortController = new AbortController();
178
+ const request = {
179
+ callId: '1',
180
+ name: 'mockTool',
181
+ args: {},
182
+ isClientInitiated: false,
183
+ prompt_id: 'prompt-id-1',
184
+ };
185
+ abortController.abort();
186
+ await scheduler.schedule([request], abortController.signal);
187
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
188
+ const completedCalls = onAllToolCallsComplete.mock
189
+ .calls[0][0];
190
+ expect(completedCalls[0].status).toBe('cancelled');
191
+ });
192
+ it('should mark tool call as cancelled when abort happens during confirmation error', async () => {
193
+ const abortController = new AbortController();
194
+ const abortError = new Error('Abort requested during confirmation');
195
+ const declarativeTool = new AbortDuringConfirmationTool(abortController, abortError);
196
+ const mockToolRegistry = {
197
+ getTool: () => declarativeTool,
198
+ getFunctionDeclarations: () => [],
199
+ tools: new Map(),
200
+ discovery: {},
201
+ registerTool: () => { },
202
+ getToolByName: () => declarativeTool,
203
+ getToolByDisplayName: () => declarativeTool,
204
+ getTools: () => [],
205
+ discoverTools: async () => { },
206
+ getAllTools: () => [],
207
+ getToolsByServer: () => [],
208
+ };
209
+ const onAllToolCallsComplete = vi.fn();
210
+ const onToolCallsUpdate = vi.fn();
211
+ const mockConfig = {
212
+ getSessionId: () => 'test-session-id',
213
+ getUsageStatisticsEnabled: () => true,
214
+ getDebugMode: () => false,
215
+ getApprovalMode: () => ApprovalMode.DEFAULT,
216
+ getAllowedTools: () => [],
217
+ getContentGeneratorConfig: () => ({
218
+ model: 'test-model',
219
+ authType: 'gemini',
220
+ }),
221
+ getShellExecutionConfig: () => ({
222
+ terminalWidth: 90,
223
+ terminalHeight: 30,
224
+ }),
225
+ storage: {
226
+ getProjectTempDir: () => '/tmp',
227
+ },
228
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
229
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
230
+ getToolRegistry: () => mockToolRegistry,
231
+ getUseModelRouter: () => false,
232
+ getGeminiClient: () => null,
233
+ getChatRecordingService: () => undefined,
234
+ };
235
+ const scheduler = new CoreToolScheduler({
236
+ config: mockConfig,
237
+ onAllToolCallsComplete,
238
+ onToolCallsUpdate,
239
+ getPreferredEditor: () => 'vscode',
240
+ onEditorClose: vi.fn(),
241
+ });
242
+ const request = {
243
+ callId: 'abort-1',
244
+ name: 'abortDuringConfirmationTool',
245
+ args: {},
246
+ isClientInitiated: false,
247
+ prompt_id: 'prompt-id-abort',
248
+ };
249
+ await scheduler.schedule([request], abortController.signal);
250
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
251
+ const completedCalls = onAllToolCallsComplete.mock
252
+ .calls[0][0];
253
+ expect(completedCalls[0].status).toBe('cancelled');
254
+ const statuses = onToolCallsUpdate.mock.calls.flatMap((call) => call[0].map((toolCall) => toolCall.status));
255
+ expect(statuses).not.toContain('error');
256
+ });
257
+ describe('getToolSuggestion', () => {
258
+ it('should suggest the top N closest tool names for a typo', () => {
259
+ // Create mocked tool registry
260
+ const mockToolRegistry = {
261
+ getAllToolNames: () => ['list_files', 'read_file', 'write_file'],
262
+ getTool: () => undefined, // No SkillTool in this test
263
+ };
264
+ const mockConfig = {
265
+ getToolRegistry: () => mockToolRegistry,
266
+ getUseModelRouter: () => false,
267
+ getGeminiClient: () => null, // No client needed for these tests
268
+ getExcludeTools: () => undefined,
269
+ isInteractive: () => true,
270
+ };
271
+ // Create scheduler
272
+ const scheduler = new CoreToolScheduler({
273
+ config: mockConfig,
274
+ getPreferredEditor: () => 'vscode',
275
+ onEditorClose: vi.fn(),
276
+ });
277
+ // Test that the right tool is selected, with only 1 result, for typos
278
+ // @ts-expect-error accessing private method
279
+ const misspelledTool = scheduler.getToolSuggestion('list_fils', 1);
280
+ expect(misspelledTool).toBe(' Did you mean "list_files"?');
281
+ // Test that the right tool is selected, with only 1 result, for prefixes
282
+ // @ts-expect-error accessing private method
283
+ const prefixedTool = scheduler.getToolSuggestion('github.list_files', 1);
284
+ expect(prefixedTool).toBe(' Did you mean "list_files"?');
285
+ // Test that the right tool is first
286
+ // @ts-expect-error accessing private method
287
+ const suggestionMultiple = scheduler.getToolSuggestion('list_fils');
288
+ expect(suggestionMultiple).toBe(' Did you mean one of: "list_files", "read_file", "write_file"?');
289
+ });
290
+ it('should use Levenshtein suggestions for excluded tools (getToolSuggestion only handles non-excluded)', () => {
291
+ // Create mocked tool registry
292
+ const mockToolRegistry = {
293
+ getAllToolNames: () => ['list_files', 'read_file'],
294
+ getTool: () => undefined, // No SkillTool in this test
295
+ };
296
+ // Create mocked config with excluded tools
297
+ const mockConfig = {
298
+ getToolRegistry: () => mockToolRegistry,
299
+ getUseModelRouter: () => false,
300
+ getGeminiClient: () => null,
301
+ getExcludeTools: () => ['write_file', 'edit', 'run_shell_command'],
302
+ isInteractive: () => false, // Value doesn't matter, but included for completeness
303
+ };
304
+ // Create scheduler
305
+ const scheduler = new CoreToolScheduler({
306
+ config: mockConfig,
307
+ getPreferredEditor: () => 'vscode',
308
+ onEditorClose: vi.fn(),
309
+ });
310
+ // getToolSuggestion no longer handles excluded tools - it only handles truly missing tools
311
+ // So excluded tools will use Levenshtein distance to find similar registered tools
312
+ // @ts-expect-error accessing private method
313
+ const excludedTool = scheduler.getToolSuggestion('write_file');
314
+ expect(excludedTool).toContain('Did you mean');
315
+ });
316
+ it('should use Levenshtein suggestions for non-excluded tools', () => {
317
+ // Create mocked tool registry
318
+ const mockToolRegistry = {
319
+ getAllToolNames: () => ['list_files', 'read_file'],
320
+ getTool: () => undefined, // No SkillTool in this test
321
+ };
322
+ // Create mocked config with excluded tools
323
+ const mockConfig = {
324
+ getToolRegistry: () => mockToolRegistry,
325
+ getUseModelRouter: () => false,
326
+ getGeminiClient: () => null,
327
+ getExcludeTools: () => ['write_file', 'edit'],
328
+ isInteractive: () => false, // Value doesn't matter
329
+ };
330
+ // Create scheduler
331
+ const scheduler = new CoreToolScheduler({
332
+ config: mockConfig,
333
+ getPreferredEditor: () => 'vscode',
334
+ onEditorClose: vi.fn(),
335
+ });
336
+ // Test that non-excluded tool (hallucinated) still uses Levenshtein suggestions
337
+ // @ts-expect-error accessing private method
338
+ const hallucinatedTool = scheduler.getToolSuggestion('list_fils');
339
+ expect(hallucinatedTool).toContain('Did you mean');
340
+ expect(hallucinatedTool).not.toContain('not available in the current environment');
341
+ });
342
+ it('should suggest using Skill tool when unknown tool name matches a skill name', () => {
343
+ // Create a mock that passes instanceof SkillTool check
344
+ const mockSkillTool = Object.create(SkillTool.prototype);
345
+ mockSkillTool.getAvailableSkillNames = () => [
346
+ 'pdf',
347
+ 'xlsx',
348
+ 'frontend-design',
349
+ ];
350
+ // Create mocked tool registry that returns the mock SkillTool
351
+ const mockToolRegistry = {
352
+ getAllToolNames: () => ['skill', 'list_files', 'read_file'],
353
+ getTool: (name) => name === 'skill' ? mockSkillTool : undefined,
354
+ };
355
+ // Create mocked config
356
+ const mockConfig = {
357
+ getToolRegistry: () => mockToolRegistry,
358
+ getUseModelRouter: () => false,
359
+ getGeminiClient: () => null,
360
+ getExcludeTools: () => undefined,
361
+ isInteractive: () => true,
362
+ };
363
+ // Create scheduler
364
+ const scheduler = new CoreToolScheduler({
365
+ config: mockConfig,
366
+ getPreferredEditor: () => 'vscode',
367
+ onEditorClose: vi.fn(),
368
+ });
369
+ // Test that when unknown tool name matches a skill name, we get skill-specific message
370
+ // @ts-expect-error accessing private method
371
+ const skillMessage = scheduler.getToolNotFoundMessage('pdf');
372
+ expect(skillMessage).toContain('is a skill name, not a tool name');
373
+ expect(skillMessage).toContain('skill');
374
+ expect(skillMessage).toContain('skill: "pdf"');
375
+ // Should NOT contain the standard "not found in registry" prefix
376
+ expect(skillMessage).not.toContain('not found in registry');
377
+ // Test another skill name
378
+ // @ts-expect-error accessing private method
379
+ const xlsxMessage = scheduler.getToolNotFoundMessage('xlsx');
380
+ expect(xlsxMessage).toContain('is a skill name, not a tool name');
381
+ expect(xlsxMessage).toContain('skill: "xlsx"');
382
+ // Test that non-skill names still use standard message with Levenshtein suggestions
383
+ // @ts-expect-error accessing private method
384
+ const nonSkillMessage = scheduler.getToolNotFoundMessage('list_fils');
385
+ expect(nonSkillMessage).toContain('not found in registry');
386
+ expect(nonSkillMessage).toContain('Did you mean');
387
+ expect(nonSkillMessage).not.toContain('is a skill name');
388
+ });
389
+ });
390
+ describe('excluded tools handling', () => {
391
+ it('should return permission error for excluded tools instead of "not found" message', async () => {
392
+ const onAllToolCallsComplete = vi.fn();
393
+ const onToolCallsUpdate = vi.fn();
394
+ const mockToolRegistry = {
395
+ getTool: () => undefined, // Tool not in registry
396
+ getAllToolNames: () => ['list_files', 'read_file'],
397
+ getFunctionDeclarations: () => [],
398
+ tools: new Map(),
399
+ discovery: {},
400
+ registerTool: () => { },
401
+ getToolByName: () => undefined,
402
+ getToolByDisplayName: () => undefined,
403
+ getTools: () => [],
404
+ discoverTools: async () => { },
405
+ getAllTools: () => [],
406
+ getToolsByServer: () => [],
407
+ };
408
+ const mockConfig = {
409
+ getSessionId: () => 'test-session-id',
410
+ getUsageStatisticsEnabled: () => true,
411
+ getDebugMode: () => false,
412
+ getApprovalMode: () => ApprovalMode.DEFAULT,
413
+ getAllowedTools: () => [],
414
+ getExcludeTools: () => ['write_file', 'edit', 'run_shell_command'],
415
+ getContentGeneratorConfig: () => ({
416
+ model: 'test-model',
417
+ authType: 'gemini',
418
+ }),
419
+ getShellExecutionConfig: () => ({
420
+ terminalWidth: 90,
421
+ terminalHeight: 30,
422
+ }),
423
+ storage: {
424
+ getProjectTempDir: () => '/tmp',
425
+ },
426
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
427
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
428
+ getToolRegistry: () => mockToolRegistry,
429
+ getUseModelRouter: () => false,
430
+ getGeminiClient: () => null,
431
+ getChatRecordingService: () => undefined,
432
+ };
433
+ const scheduler = new CoreToolScheduler({
434
+ config: mockConfig,
435
+ onAllToolCallsComplete,
436
+ onToolCallsUpdate,
437
+ getPreferredEditor: () => 'vscode',
438
+ onEditorClose: vi.fn(),
439
+ });
440
+ const abortController = new AbortController();
441
+ const request = {
442
+ callId: '1',
443
+ name: 'write_file', // Excluded tool
444
+ args: {},
445
+ isClientInitiated: false,
446
+ prompt_id: 'prompt-id-excluded',
447
+ };
448
+ await scheduler.schedule([request], abortController.signal);
449
+ // Wait for completion
450
+ await vi.waitFor(() => {
451
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
452
+ });
453
+ const completedCalls = onAllToolCallsComplete.mock
454
+ .calls[0][0];
455
+ expect(completedCalls).toHaveLength(1);
456
+ const completedCall = completedCalls[0];
457
+ expect(completedCall.status).toBe('error');
458
+ if (completedCall.status === 'error') {
459
+ const errorMessage = completedCall.response.error?.message;
460
+ expect(errorMessage).toBe('Qwen Code requires permission to use write_file, but that permission was declined.');
461
+ // Should NOT contain "not found in registry"
462
+ expect(errorMessage).not.toContain('not found in registry');
463
+ }
464
+ });
465
+ it('should return "not found" message for truly missing tools (not excluded)', async () => {
466
+ const onAllToolCallsComplete = vi.fn();
467
+ const onToolCallsUpdate = vi.fn();
468
+ const mockToolRegistry = {
469
+ getTool: () => undefined, // Tool not in registry
470
+ getAllToolNames: () => ['list_files', 'read_file'],
471
+ getFunctionDeclarations: () => [],
472
+ tools: new Map(),
473
+ discovery: {},
474
+ registerTool: () => { },
475
+ getToolByName: () => undefined,
476
+ getToolByDisplayName: () => undefined,
477
+ getTools: () => [],
478
+ discoverTools: async () => { },
479
+ getAllTools: () => [],
480
+ getToolsByServer: () => [],
481
+ };
482
+ const mockConfig = {
483
+ getSessionId: () => 'test-session-id',
484
+ getUsageStatisticsEnabled: () => true,
485
+ getDebugMode: () => false,
486
+ getApprovalMode: () => ApprovalMode.DEFAULT,
487
+ getAllowedTools: () => [],
488
+ getExcludeTools: () => ['write_file', 'edit'], // Different excluded tools
489
+ getContentGeneratorConfig: () => ({
490
+ model: 'test-model',
491
+ authType: 'gemini',
492
+ }),
493
+ getShellExecutionConfig: () => ({
494
+ terminalWidth: 90,
495
+ terminalHeight: 30,
496
+ }),
497
+ storage: {
498
+ getProjectTempDir: () => '/tmp',
499
+ },
500
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
501
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
502
+ getToolRegistry: () => mockToolRegistry,
503
+ getUseModelRouter: () => false,
504
+ getGeminiClient: () => null,
505
+ getChatRecordingService: () => undefined,
506
+ };
507
+ const scheduler = new CoreToolScheduler({
508
+ config: mockConfig,
509
+ onAllToolCallsComplete,
510
+ onToolCallsUpdate,
511
+ getPreferredEditor: () => 'vscode',
512
+ onEditorClose: vi.fn(),
513
+ });
514
+ const abortController = new AbortController();
515
+ const request = {
516
+ callId: '1',
517
+ name: 'nonexistent_tool', // Not excluded, just doesn't exist
518
+ args: {},
519
+ isClientInitiated: false,
520
+ prompt_id: 'prompt-id-missing',
521
+ };
522
+ await scheduler.schedule([request], abortController.signal);
523
+ // Wait for completion
524
+ await vi.waitFor(() => {
525
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
526
+ });
527
+ const completedCalls = onAllToolCallsComplete.mock
528
+ .calls[0][0];
529
+ expect(completedCalls).toHaveLength(1);
530
+ const completedCall = completedCalls[0];
531
+ expect(completedCall.status).toBe('error');
532
+ if (completedCall.status === 'error') {
533
+ const errorMessage = completedCall.response.error?.message;
534
+ // Should contain "not found in registry"
535
+ expect(errorMessage).toContain('not found in registry');
536
+ // Should NOT contain permission message
537
+ expect(errorMessage).not.toContain('requires permission');
538
+ }
539
+ });
540
+ });
541
+ });
542
+ describe('CoreToolScheduler with payload', () => {
543
+ it('should update args and diff and execute tool when payload is provided', async () => {
544
+ const mockTool = new MockModifiableTool();
545
+ mockTool.executeFn = vi.fn();
546
+ const declarativeTool = mockTool;
547
+ const mockToolRegistry = {
548
+ getTool: () => declarativeTool,
549
+ getFunctionDeclarations: () => [],
550
+ tools: new Map(),
551
+ discovery: {},
552
+ registerTool: () => { },
553
+ getToolByName: () => declarativeTool,
554
+ getToolByDisplayName: () => declarativeTool,
555
+ getTools: () => [],
556
+ discoverTools: async () => { },
557
+ getAllTools: () => [],
558
+ getToolsByServer: () => [],
559
+ };
560
+ const onAllToolCallsComplete = vi.fn();
561
+ const onToolCallsUpdate = vi.fn();
562
+ const mockConfig = {
563
+ getSessionId: () => 'test-session-id',
564
+ getUsageStatisticsEnabled: () => true,
565
+ getDebugMode: () => false,
566
+ getApprovalMode: () => ApprovalMode.DEFAULT,
567
+ getAllowedTools: () => [],
568
+ getContentGeneratorConfig: () => ({
569
+ model: 'test-model',
570
+ authType: 'gemini',
571
+ }),
572
+ getShellExecutionConfig: () => ({
573
+ terminalWidth: 90,
574
+ terminalHeight: 30,
575
+ }),
576
+ storage: {
577
+ getProjectTempDir: () => '/tmp',
578
+ },
579
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
580
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
581
+ getToolRegistry: () => mockToolRegistry,
582
+ getUseModelRouter: () => false,
583
+ getGeminiClient: () => null, // No client needed for these tests
584
+ isInteractive: () => true, // Required to prevent auto-denial of tool calls
585
+ getIdeMode: () => false,
586
+ getExperimentalZedIntegration: () => false,
587
+ getChatRecordingService: () => undefined,
588
+ };
589
+ const scheduler = new CoreToolScheduler({
590
+ config: mockConfig,
591
+ onAllToolCallsComplete,
592
+ onToolCallsUpdate,
593
+ getPreferredEditor: () => 'vscode',
594
+ onEditorClose: vi.fn(),
595
+ });
596
+ const abortController = new AbortController();
597
+ const request = {
598
+ callId: '1',
599
+ name: 'mockModifiableTool',
600
+ args: {},
601
+ isClientInitiated: false,
602
+ prompt_id: 'prompt-id-2',
603
+ };
604
+ await scheduler.schedule([request], abortController.signal);
605
+ const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
606
+ const confirmationDetails = awaitingCall.confirmationDetails;
607
+ if (confirmationDetails) {
608
+ const payload = { newContent: 'final version' };
609
+ await confirmationDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce, payload);
610
+ }
611
+ // Wait for the tool execution to complete
612
+ await vi.waitFor(() => {
613
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
614
+ });
615
+ const completedCalls = onAllToolCallsComplete.mock
616
+ .calls[0][0];
617
+ expect(completedCalls[0].status).toBe('success');
618
+ expect(mockTool.executeFn).toHaveBeenCalledWith({
619
+ newContent: 'final version',
620
+ });
621
+ });
622
+ });
623
+ describe('convertToFunctionResponse', () => {
624
+ const toolName = 'testTool';
625
+ const callId = 'call1';
626
+ it('should handle simple string llmContent', () => {
627
+ const llmContent = 'Simple text output';
628
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
629
+ expect(result).toEqual([
630
+ {
631
+ functionResponse: {
632
+ name: toolName,
633
+ id: callId,
634
+ response: { output: 'Simple text output' },
635
+ },
636
+ },
637
+ ]);
638
+ });
639
+ it('should handle llmContent as a single Part with text', () => {
640
+ const llmContent = { text: 'Text from Part object' };
641
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
642
+ expect(result).toEqual([
643
+ {
644
+ functionResponse: {
645
+ name: toolName,
646
+ id: callId,
647
+ response: { output: 'Text from Part object' },
648
+ },
649
+ },
650
+ ]);
651
+ });
652
+ it('should handle llmContent as a PartListUnion array with a single text Part', () => {
653
+ const llmContent = [{ text: 'Text from array' }];
654
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
655
+ expect(result).toEqual([
656
+ {
657
+ functionResponse: {
658
+ name: toolName,
659
+ id: callId,
660
+ response: { output: 'Text from array' },
661
+ },
662
+ },
663
+ ]);
664
+ });
665
+ it('should handle llmContent with inlineData', () => {
666
+ const llmContent = {
667
+ inlineData: { mimeType: 'image/png', data: 'base64...' },
668
+ };
669
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
670
+ expect(result).toEqual([
671
+ {
672
+ functionResponse: {
673
+ name: toolName,
674
+ id: callId,
675
+ response: {
676
+ output: '',
677
+ },
678
+ parts: [{ inlineData: { mimeType: 'image/png', data: 'base64...' } }],
679
+ },
680
+ },
681
+ ]);
682
+ });
683
+ it('should handle llmContent with fileData', () => {
684
+ const llmContent = {
685
+ fileData: { mimeType: 'application/pdf', fileUri: 'gs://...' },
686
+ };
687
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
688
+ expect(result).toEqual([
689
+ {
690
+ functionResponse: {
691
+ name: toolName,
692
+ id: callId,
693
+ response: {
694
+ output: '',
695
+ },
696
+ parts: [
697
+ {
698
+ fileData: { mimeType: 'application/pdf', fileUri: 'gs://...' },
699
+ },
700
+ ],
701
+ },
702
+ },
703
+ ]);
704
+ });
705
+ it('should handle llmContent as an array of multiple Parts (text and inlineData)', () => {
706
+ const llmContent = [
707
+ { text: 'Some textual description' },
708
+ { inlineData: { mimeType: 'image/jpeg', data: 'base64data...' } },
709
+ { text: 'Another text part' },
710
+ ];
711
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
712
+ // All content should be inside the FunctionResponse:
713
+ // - text parts joined into response.output
714
+ // - media parts in response.parts
715
+ expect(result).toEqual([
716
+ {
717
+ functionResponse: {
718
+ name: toolName,
719
+ id: callId,
720
+ response: {
721
+ output: 'Some textual description\nAnother text part',
722
+ },
723
+ parts: [
724
+ { inlineData: { mimeType: 'image/jpeg', data: 'base64data...' } },
725
+ ],
726
+ },
727
+ },
728
+ ]);
729
+ });
730
+ it('should handle llmContent as an array with a single inlineData Part', () => {
731
+ const llmContent = [
732
+ { inlineData: { mimeType: 'image/gif', data: 'gifdata...' } },
733
+ ];
734
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
735
+ expect(result).toEqual([
736
+ {
737
+ functionResponse: {
738
+ name: toolName,
739
+ id: callId,
740
+ response: {
741
+ output: '',
742
+ },
743
+ parts: [
744
+ { inlineData: { mimeType: 'image/gif', data: 'gifdata...' } },
745
+ ],
746
+ },
747
+ },
748
+ ]);
749
+ });
750
+ it('should handle llmContent as a generic Part (not text, inlineData, or fileData)', () => {
751
+ const llmContent = { functionCall: { name: 'test', args: {} } };
752
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
753
+ expect(result).toEqual([
754
+ {
755
+ functionResponse: {
756
+ name: toolName,
757
+ id: callId,
758
+ response: { output: 'Tool execution succeeded.' },
759
+ },
760
+ },
761
+ ]);
762
+ });
763
+ it('should handle empty string llmContent', () => {
764
+ const llmContent = '';
765
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
766
+ expect(result).toEqual([
767
+ {
768
+ functionResponse: {
769
+ name: toolName,
770
+ id: callId,
771
+ response: { output: '' },
772
+ },
773
+ },
774
+ ]);
775
+ });
776
+ it('should handle llmContent as an empty array', () => {
777
+ const llmContent = [];
778
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
779
+ expect(result).toEqual([
780
+ {
781
+ functionResponse: {
782
+ name: toolName,
783
+ id: callId,
784
+ response: { output: 'Tool execution succeeded.' },
785
+ },
786
+ },
787
+ ]);
788
+ });
789
+ it('should handle llmContent as a Part with undefined inlineData/fileData/text', () => {
790
+ const llmContent = {}; // An empty part object
791
+ const result = convertToFunctionResponse(toolName, callId, llmContent);
792
+ expect(result).toEqual([
793
+ {
794
+ functionResponse: {
795
+ name: toolName,
796
+ id: callId,
797
+ response: { output: 'Tool execution succeeded.' },
798
+ },
799
+ },
800
+ ]);
801
+ });
802
+ });
803
+ class MockEditToolInvocation extends BaseToolInvocation {
804
+ constructor(params) {
805
+ super(params);
806
+ }
807
+ getDescription() {
808
+ return 'A mock edit tool invocation';
809
+ }
810
+ async shouldConfirmExecute(_abortSignal) {
811
+ return {
812
+ type: 'edit',
813
+ title: 'Confirm Edit',
814
+ fileName: 'test.txt',
815
+ filePath: 'test.txt',
816
+ fileDiff: '--- test.txt\n+++ test.txt\n@@ -1,1 +1,1 @@\n-old content\n+new content',
817
+ originalContent: 'old content',
818
+ newContent: 'new content',
819
+ onConfirm: async () => { },
820
+ };
821
+ }
822
+ async execute(_abortSignal) {
823
+ return {
824
+ llmContent: 'Edited successfully',
825
+ returnDisplay: 'Edited successfully',
826
+ };
827
+ }
828
+ }
829
+ class MockEditTool extends BaseDeclarativeTool {
830
+ constructor() {
831
+ super('mockEditTool', 'mockEditTool', 'A mock edit tool', Kind.Edit, {});
832
+ }
833
+ createInvocation(params) {
834
+ return new MockEditToolInvocation(params);
835
+ }
836
+ }
837
+ describe('CoreToolScheduler edit cancellation', () => {
838
+ it('should preserve diff when an edit is cancelled', async () => {
839
+ const mockEditTool = new MockEditTool();
840
+ const mockToolRegistry = {
841
+ getTool: () => mockEditTool,
842
+ getFunctionDeclarations: () => [],
843
+ tools: new Map(),
844
+ discovery: {},
845
+ registerTool: () => { },
846
+ getToolByName: () => mockEditTool,
847
+ getToolByDisplayName: () => mockEditTool,
848
+ getTools: () => [],
849
+ discoverTools: async () => { },
850
+ getAllTools: () => [],
851
+ getToolsByServer: () => [],
852
+ };
853
+ const onAllToolCallsComplete = vi.fn();
854
+ const onToolCallsUpdate = vi.fn();
855
+ const mockConfig = {
856
+ getSessionId: () => 'test-session-id',
857
+ getUsageStatisticsEnabled: () => true,
858
+ getDebugMode: () => false,
859
+ getApprovalMode: () => ApprovalMode.DEFAULT,
860
+ getAllowedTools: () => [],
861
+ getContentGeneratorConfig: () => ({
862
+ model: 'test-model',
863
+ authType: 'gemini',
864
+ }),
865
+ getShellExecutionConfig: () => ({
866
+ terminalWidth: 90,
867
+ terminalHeight: 30,
868
+ }),
869
+ storage: {
870
+ getProjectTempDir: () => '/tmp',
871
+ },
872
+ getToolRegistry: () => mockToolRegistry,
873
+ getUseModelRouter: () => false,
874
+ getGeminiClient: () => null, // No client needed for these tests
875
+ isInteractive: () => true, // Required to prevent auto-denial of tool calls
876
+ getIdeMode: () => false,
877
+ getExperimentalZedIntegration: () => false,
878
+ getChatRecordingService: () => undefined,
879
+ };
880
+ const scheduler = new CoreToolScheduler({
881
+ config: mockConfig,
882
+ onAllToolCallsComplete,
883
+ onToolCallsUpdate,
884
+ getPreferredEditor: () => 'vscode',
885
+ onEditorClose: vi.fn(),
886
+ });
887
+ const abortController = new AbortController();
888
+ const request = {
889
+ callId: '1',
890
+ name: 'mockEditTool',
891
+ args: {},
892
+ isClientInitiated: false,
893
+ prompt_id: 'prompt-id-1',
894
+ };
895
+ await scheduler.schedule([request], abortController.signal);
896
+ const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
897
+ // Cancel the edit
898
+ const confirmationDetails = awaitingCall.confirmationDetails;
899
+ if (confirmationDetails) {
900
+ await confirmationDetails.onConfirm(ToolConfirmationOutcome.Cancel);
901
+ }
902
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
903
+ const completedCalls = onAllToolCallsComplete.mock
904
+ .calls[0][0];
905
+ expect(completedCalls[0].status).toBe('cancelled');
906
+ // Check that the diff is preserved
907
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
908
+ const cancelledCall = completedCalls[0];
909
+ expect(cancelledCall.response.resultDisplay).toBeDefined();
910
+ expect(cancelledCall.response.resultDisplay.fileDiff).toBe('--- test.txt\n+++ test.txt\n@@ -1,1 +1,1 @@\n-old content\n+new content');
911
+ expect(cancelledCall.response.resultDisplay.fileName).toBe('test.txt');
912
+ });
913
+ });
914
+ describe('CoreToolScheduler YOLO mode', () => {
915
+ it('should execute tool requiring confirmation directly without waiting', async () => {
916
+ // Arrange
917
+ const executeFn = vi.fn().mockResolvedValue({
918
+ llmContent: 'Tool executed',
919
+ returnDisplay: 'Tool executed',
920
+ });
921
+ const mockTool = new MockTool({
922
+ name: 'mockTool',
923
+ execute: executeFn,
924
+ shouldConfirmExecute: MOCK_TOOL_SHOULD_CONFIRM_EXECUTE,
925
+ });
926
+ const declarativeTool = mockTool;
927
+ const mockToolRegistry = {
928
+ getTool: () => declarativeTool,
929
+ getToolByName: () => declarativeTool,
930
+ // Other properties are not needed for this test but are included for type consistency.
931
+ getFunctionDeclarations: () => [],
932
+ tools: new Map(),
933
+ discovery: {},
934
+ registerTool: () => { },
935
+ getToolByDisplayName: () => declarativeTool,
936
+ getTools: () => [],
937
+ discoverTools: async () => { },
938
+ getAllTools: () => [],
939
+ getToolsByServer: () => [],
940
+ };
941
+ const onAllToolCallsComplete = vi.fn();
942
+ const onToolCallsUpdate = vi.fn();
943
+ // Configure the scheduler for YOLO mode.
944
+ const mockConfig = {
945
+ getSessionId: () => 'test-session-id',
946
+ getUsageStatisticsEnabled: () => true,
947
+ getDebugMode: () => false,
948
+ getApprovalMode: () => ApprovalMode.YOLO,
949
+ getAllowedTools: () => [],
950
+ getContentGeneratorConfig: () => ({
951
+ model: 'test-model',
952
+ authType: 'gemini',
953
+ }),
954
+ getShellExecutionConfig: () => ({
955
+ terminalWidth: 90,
956
+ terminalHeight: 30,
957
+ }),
958
+ storage: {
959
+ getProjectTempDir: () => '/tmp',
960
+ },
961
+ getToolRegistry: () => mockToolRegistry,
962
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
963
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
964
+ getUseModelRouter: () => false,
965
+ getGeminiClient: () => null, // No client needed for these tests
966
+ getChatRecordingService: () => undefined,
967
+ };
968
+ const scheduler = new CoreToolScheduler({
969
+ config: mockConfig,
970
+ onAllToolCallsComplete,
971
+ onToolCallsUpdate,
972
+ getPreferredEditor: () => 'vscode',
973
+ onEditorClose: vi.fn(),
974
+ });
975
+ const abortController = new AbortController();
976
+ const request = {
977
+ callId: '1',
978
+ name: 'mockTool',
979
+ args: { param: 'value' },
980
+ isClientInitiated: false,
981
+ prompt_id: 'prompt-id-yolo',
982
+ };
983
+ // Act
984
+ await scheduler.schedule([request], abortController.signal);
985
+ // Wait for the tool execution to complete
986
+ await vi.waitFor(() => {
987
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
988
+ });
989
+ // Assert
990
+ // 1. The tool's execute method was called directly.
991
+ expect(executeFn).toHaveBeenCalledWith({ param: 'value' });
992
+ // 2. The tool call status never entered 'awaiting_approval'.
993
+ const statusUpdates = onToolCallsUpdate.mock.calls
994
+ .map((call) => call[0][0]?.status)
995
+ .filter(Boolean);
996
+ expect(statusUpdates).not.toContain('awaiting_approval');
997
+ expect(statusUpdates).toEqual([
998
+ 'validating',
999
+ 'scheduled',
1000
+ 'executing',
1001
+ 'success',
1002
+ ]);
1003
+ // 3. The final callback indicates the tool call was successful.
1004
+ const completedCalls = onAllToolCallsComplete.mock
1005
+ .calls[0][0];
1006
+ expect(completedCalls).toHaveLength(1);
1007
+ const completedCall = completedCalls[0];
1008
+ expect(completedCall.status).toBe('success');
1009
+ if (completedCall.status === 'success') {
1010
+ expect(completedCall.response.resultDisplay).toBe('Tool executed');
1011
+ }
1012
+ });
1013
+ });
1014
+ describe('CoreToolScheduler cancellation during executing with live output', () => {
1015
+ it('sets status to cancelled and preserves last output', async () => {
1016
+ class StreamingInvocation extends BaseToolInvocation {
1017
+ getDescription() {
1018
+ return `Streaming tool ${this.params.id}`;
1019
+ }
1020
+ async execute(signal, updateOutput) {
1021
+ updateOutput?.('hello');
1022
+ // Wait until aborted to emulate a long-running task
1023
+ await new Promise((resolve) => {
1024
+ if (signal.aborted)
1025
+ return resolve();
1026
+ const onAbort = () => {
1027
+ signal.removeEventListener('abort', onAbort);
1028
+ resolve();
1029
+ };
1030
+ signal.addEventListener('abort', onAbort, { once: true });
1031
+ });
1032
+ // Return a normal (non-error) result; scheduler should still mark cancelled
1033
+ return { llmContent: 'done', returnDisplay: 'done' };
1034
+ }
1035
+ }
1036
+ class StreamingTool extends BaseDeclarativeTool {
1037
+ constructor() {
1038
+ super('stream-tool', 'Stream Tool', 'Emits live output and waits for abort', Kind.Other, {
1039
+ type: 'object',
1040
+ properties: { id: { type: 'string' } },
1041
+ required: ['id'],
1042
+ }, true, true);
1043
+ }
1044
+ createInvocation(params) {
1045
+ return new StreamingInvocation(params);
1046
+ }
1047
+ }
1048
+ const tool = new StreamingTool();
1049
+ const mockToolRegistry = {
1050
+ getTool: () => tool,
1051
+ getFunctionDeclarations: () => [],
1052
+ tools: new Map(),
1053
+ discovery: {},
1054
+ registerTool: () => { },
1055
+ getToolByName: () => tool,
1056
+ getToolByDisplayName: () => tool,
1057
+ getTools: () => [],
1058
+ discoverTools: async () => { },
1059
+ getAllTools: () => [],
1060
+ getToolsByServer: () => [],
1061
+ };
1062
+ const onAllToolCallsComplete = vi.fn();
1063
+ const onToolCallsUpdate = vi.fn();
1064
+ const mockConfig = {
1065
+ getSessionId: () => 'test-session-id',
1066
+ getUsageStatisticsEnabled: () => true,
1067
+ getDebugMode: () => false,
1068
+ getApprovalMode: () => ApprovalMode.DEFAULT,
1069
+ getContentGeneratorConfig: () => ({
1070
+ model: 'test-model',
1071
+ authType: 'gemini',
1072
+ }),
1073
+ getToolRegistry: () => mockToolRegistry,
1074
+ getShellExecutionConfig: () => ({
1075
+ terminalWidth: 90,
1076
+ terminalHeight: 30,
1077
+ }),
1078
+ getChatRecordingService: () => undefined,
1079
+ };
1080
+ const scheduler = new CoreToolScheduler({
1081
+ config: mockConfig,
1082
+ onAllToolCallsComplete,
1083
+ onToolCallsUpdate,
1084
+ getPreferredEditor: () => 'vscode',
1085
+ onEditorClose: vi.fn(),
1086
+ });
1087
+ const abortController = new AbortController();
1088
+ const request = {
1089
+ callId: '1',
1090
+ name: 'stream-tool',
1091
+ args: { id: 'x' },
1092
+ isClientInitiated: true,
1093
+ prompt_id: 'prompt-stream',
1094
+ };
1095
+ const schedulePromise = scheduler.schedule([request], abortController.signal);
1096
+ // Wait until executing
1097
+ await vi.waitFor(() => {
1098
+ const calls = onToolCallsUpdate.mock.calls;
1099
+ const last = calls[calls.length - 1]?.[0][0];
1100
+ expect(last?.status).toBe('executing');
1101
+ });
1102
+ // Now abort
1103
+ abortController.abort();
1104
+ await schedulePromise;
1105
+ await vi.waitFor(() => {
1106
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1107
+ });
1108
+ const completedCalls = onAllToolCallsComplete.mock
1109
+ .calls[0][0];
1110
+ expect(completedCalls[0].status).toBe('cancelled');
1111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1112
+ const cancelled = completedCalls[0];
1113
+ expect(cancelled.response.resultDisplay).toBe('hello');
1114
+ });
1115
+ });
1116
+ describe('CoreToolScheduler request queueing', () => {
1117
+ it('should queue a request if another is running', async () => {
1118
+ let resolveFirstCall;
1119
+ const firstCallPromise = new Promise((resolve) => {
1120
+ resolveFirstCall = resolve;
1121
+ });
1122
+ const executeFn = vi.fn().mockImplementation(() => firstCallPromise);
1123
+ const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
1124
+ const declarativeTool = mockTool;
1125
+ const mockToolRegistry = {
1126
+ getTool: () => declarativeTool,
1127
+ getToolByName: () => declarativeTool,
1128
+ getFunctionDeclarations: () => [],
1129
+ tools: new Map(),
1130
+ discovery: {},
1131
+ registerTool: () => { },
1132
+ getToolByDisplayName: () => declarativeTool,
1133
+ getTools: () => [],
1134
+ discoverTools: async () => { },
1135
+ getAllTools: () => [],
1136
+ getToolsByServer: () => [],
1137
+ };
1138
+ const onAllToolCallsComplete = vi.fn();
1139
+ const onToolCallsUpdate = vi.fn();
1140
+ const mockConfig = {
1141
+ getSessionId: () => 'test-session-id',
1142
+ getUsageStatisticsEnabled: () => true,
1143
+ getDebugMode: () => false,
1144
+ getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
1145
+ getAllowedTools: () => [],
1146
+ getContentGeneratorConfig: () => ({
1147
+ model: 'test-model',
1148
+ authType: 'gemini',
1149
+ }),
1150
+ getShellExecutionConfig: () => ({
1151
+ terminalWidth: 90,
1152
+ terminalHeight: 30,
1153
+ }),
1154
+ storage: {
1155
+ getProjectTempDir: () => '/tmp',
1156
+ },
1157
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1158
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1159
+ getToolRegistry: () => mockToolRegistry,
1160
+ getUseModelRouter: () => false,
1161
+ getGeminiClient: () => null, // No client needed for these tests
1162
+ getChatRecordingService: () => undefined,
1163
+ };
1164
+ const scheduler = new CoreToolScheduler({
1165
+ config: mockConfig,
1166
+ onAllToolCallsComplete,
1167
+ onToolCallsUpdate,
1168
+ getPreferredEditor: () => 'vscode',
1169
+ onEditorClose: vi.fn(),
1170
+ });
1171
+ const abortController = new AbortController();
1172
+ const request1 = {
1173
+ callId: '1',
1174
+ name: 'mockTool',
1175
+ args: { a: 1 },
1176
+ isClientInitiated: false,
1177
+ prompt_id: 'prompt-1',
1178
+ };
1179
+ const request2 = {
1180
+ callId: '2',
1181
+ name: 'mockTool',
1182
+ args: { b: 2 },
1183
+ isClientInitiated: false,
1184
+ prompt_id: 'prompt-2',
1185
+ };
1186
+ // Schedule the first call, which will pause execution.
1187
+ scheduler.schedule([request1], abortController.signal);
1188
+ // Wait for the first call to be in the 'executing' state.
1189
+ await waitForStatus(onToolCallsUpdate, 'executing');
1190
+ // Schedule the second call while the first is "running".
1191
+ const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
1192
+ // Ensure the second tool call hasn't been executed yet.
1193
+ expect(executeFn).toHaveBeenCalledWith({ a: 1 });
1194
+ // Complete the first tool call.
1195
+ resolveFirstCall({
1196
+ llmContent: 'First call complete',
1197
+ returnDisplay: 'First call complete',
1198
+ });
1199
+ // Wait for the second schedule promise to resolve.
1200
+ await schedulePromise2;
1201
+ // Let the second call finish.
1202
+ const secondCallResult = {
1203
+ llmContent: 'Second call complete',
1204
+ returnDisplay: 'Second call complete',
1205
+ };
1206
+ // Since the mock is shared, we need to resolve the current promise.
1207
+ // In a real scenario, a new promise would be created for the second call.
1208
+ resolveFirstCall(secondCallResult);
1209
+ await vi.waitFor(() => {
1210
+ // Now the second tool call should have been executed.
1211
+ expect(executeFn).toHaveBeenCalledTimes(2);
1212
+ });
1213
+ expect(executeFn).toHaveBeenCalledWith({ b: 2 });
1214
+ // Wait for the second completion.
1215
+ await vi.waitFor(() => {
1216
+ expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
1217
+ });
1218
+ // Verify the completion callbacks were called correctly.
1219
+ expect(onAllToolCallsComplete.mock.calls[0][0][0].status).toBe('success');
1220
+ expect(onAllToolCallsComplete.mock.calls[1][0][0].status).toBe('success');
1221
+ });
1222
+ it('should auto-approve a tool call if it is on the allowedTools list', async () => {
1223
+ // Arrange
1224
+ const executeFn = vi.fn().mockResolvedValue({
1225
+ llmContent: 'Tool executed',
1226
+ returnDisplay: 'Tool executed',
1227
+ });
1228
+ const mockTool = new MockTool({
1229
+ name: 'mockTool',
1230
+ execute: executeFn,
1231
+ shouldConfirmExecute: MOCK_TOOL_SHOULD_CONFIRM_EXECUTE,
1232
+ });
1233
+ const declarativeTool = mockTool;
1234
+ const toolRegistry = {
1235
+ getTool: () => declarativeTool,
1236
+ getToolByName: () => declarativeTool,
1237
+ getFunctionDeclarations: () => [],
1238
+ tools: new Map(),
1239
+ discovery: {},
1240
+ registerTool: () => { },
1241
+ getToolByDisplayName: () => declarativeTool,
1242
+ getTools: () => [],
1243
+ discoverTools: async () => { },
1244
+ getAllTools: () => [],
1245
+ getToolsByServer: () => [],
1246
+ };
1247
+ const onAllToolCallsComplete = vi.fn();
1248
+ const onToolCallsUpdate = vi.fn();
1249
+ // Configure the scheduler to auto-approve the specific tool call.
1250
+ const mockConfig = {
1251
+ getSessionId: () => 'test-session-id',
1252
+ getUsageStatisticsEnabled: () => true,
1253
+ getDebugMode: () => false,
1254
+ getApprovalMode: () => ApprovalMode.DEFAULT, // Not YOLO mode
1255
+ getAllowedTools: () => ['mockTool'], // Auto-approve this tool
1256
+ getToolRegistry: () => toolRegistry,
1257
+ getContentGeneratorConfig: () => ({
1258
+ model: 'test-model',
1259
+ authType: 'gemini',
1260
+ }),
1261
+ getShellExecutionConfig: () => ({
1262
+ terminalWidth: 80,
1263
+ terminalHeight: 24,
1264
+ }),
1265
+ getTerminalWidth: vi.fn(() => 80),
1266
+ getTerminalHeight: vi.fn(() => 24),
1267
+ storage: {
1268
+ getProjectTempDir: () => '/tmp',
1269
+ },
1270
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1271
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1272
+ getUseModelRouter: () => false,
1273
+ getGeminiClient: () => null, // No client needed for these tests
1274
+ getChatRecordingService: () => undefined,
1275
+ };
1276
+ const scheduler = new CoreToolScheduler({
1277
+ config: mockConfig,
1278
+ onAllToolCallsComplete,
1279
+ onToolCallsUpdate,
1280
+ getPreferredEditor: () => 'vscode',
1281
+ onEditorClose: vi.fn(),
1282
+ });
1283
+ const abortController = new AbortController();
1284
+ const request = {
1285
+ callId: '1',
1286
+ name: 'mockTool',
1287
+ args: { param: 'value' },
1288
+ isClientInitiated: false,
1289
+ prompt_id: 'prompt-auto-approved',
1290
+ };
1291
+ // Act
1292
+ await scheduler.schedule([request], abortController.signal);
1293
+ // Wait for the tool execution to complete
1294
+ await vi.waitFor(() => {
1295
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1296
+ });
1297
+ // Assert
1298
+ // 1. The tool's execute method was called directly.
1299
+ expect(executeFn).toHaveBeenCalledWith({ param: 'value' });
1300
+ // 2. The tool call status never entered 'awaiting_approval'.
1301
+ const statusUpdates = onToolCallsUpdate.mock.calls
1302
+ .map((call) => call[0][0]?.status)
1303
+ .filter(Boolean);
1304
+ expect(statusUpdates).not.toContain('awaiting_approval');
1305
+ expect(statusUpdates).toEqual([
1306
+ 'validating',
1307
+ 'scheduled',
1308
+ 'executing',
1309
+ 'success',
1310
+ ]);
1311
+ // 3. The final callback indicates the tool call was successful.
1312
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1313
+ const completedCalls = onAllToolCallsComplete.mock
1314
+ .calls[0][0];
1315
+ expect(completedCalls).toHaveLength(1);
1316
+ const completedCall = completedCalls[0];
1317
+ expect(completedCall.status).toBe('success');
1318
+ if (completedCall.status === 'success') {
1319
+ expect(completedCall.response.resultDisplay).toBe('Tool executed');
1320
+ }
1321
+ });
1322
+ it('should handle two synchronous calls to schedule', async () => {
1323
+ const executeFn = vi.fn().mockResolvedValue({
1324
+ llmContent: 'Tool executed',
1325
+ returnDisplay: 'Tool executed',
1326
+ });
1327
+ const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
1328
+ const declarativeTool = mockTool;
1329
+ const mockToolRegistry = {
1330
+ getTool: () => declarativeTool,
1331
+ getToolByName: () => declarativeTool,
1332
+ getFunctionDeclarations: () => [],
1333
+ tools: new Map(),
1334
+ discovery: {},
1335
+ registerTool: () => { },
1336
+ getToolByDisplayName: () => declarativeTool,
1337
+ getTools: () => [],
1338
+ discoverTools: async () => { },
1339
+ getAllTools: () => [],
1340
+ getToolsByServer: () => [],
1341
+ };
1342
+ const onAllToolCallsComplete = vi.fn();
1343
+ const onToolCallsUpdate = vi.fn();
1344
+ const mockConfig = {
1345
+ getSessionId: () => 'test-session-id',
1346
+ getUsageStatisticsEnabled: () => true,
1347
+ getDebugMode: () => false,
1348
+ getApprovalMode: () => ApprovalMode.YOLO,
1349
+ getAllowedTools: () => [],
1350
+ getContentGeneratorConfig: () => ({
1351
+ model: 'test-model',
1352
+ authType: 'gemini',
1353
+ }),
1354
+ getShellExecutionConfig: () => ({
1355
+ terminalWidth: 90,
1356
+ terminalHeight: 30,
1357
+ }),
1358
+ storage: {
1359
+ getProjectTempDir: () => '/tmp',
1360
+ },
1361
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1362
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1363
+ getToolRegistry: () => mockToolRegistry,
1364
+ getUseModelRouter: () => false,
1365
+ getGeminiClient: () => null, // No client needed for these tests
1366
+ getChatRecordingService: () => undefined,
1367
+ };
1368
+ const scheduler = new CoreToolScheduler({
1369
+ config: mockConfig,
1370
+ onAllToolCallsComplete,
1371
+ onToolCallsUpdate,
1372
+ getPreferredEditor: () => 'vscode',
1373
+ onEditorClose: vi.fn(),
1374
+ });
1375
+ const abortController = new AbortController();
1376
+ const request1 = {
1377
+ callId: '1',
1378
+ name: 'mockTool',
1379
+ args: { a: 1 },
1380
+ isClientInitiated: false,
1381
+ prompt_id: 'prompt-1',
1382
+ };
1383
+ const request2 = {
1384
+ callId: '2',
1385
+ name: 'mockTool',
1386
+ args: { b: 2 },
1387
+ isClientInitiated: false,
1388
+ prompt_id: 'prompt-2',
1389
+ };
1390
+ // Schedule two calls synchronously.
1391
+ const schedulePromise1 = scheduler.schedule([request1], abortController.signal);
1392
+ const schedulePromise2 = scheduler.schedule([request2], abortController.signal);
1393
+ // Wait for both promises to resolve.
1394
+ await Promise.all([schedulePromise1, schedulePromise2]);
1395
+ // Ensure the tool was called twice with the correct arguments.
1396
+ expect(executeFn).toHaveBeenCalledTimes(2);
1397
+ expect(executeFn).toHaveBeenCalledWith({ a: 1 });
1398
+ expect(executeFn).toHaveBeenCalledWith({ b: 2 });
1399
+ // Ensure completion callbacks were called twice.
1400
+ expect(onAllToolCallsComplete).toHaveBeenCalledTimes(2);
1401
+ });
1402
+ it('should auto-approve remaining tool calls when first tool call is approved with ProceedAlways', async () => {
1403
+ let approvalMode = ApprovalMode.DEFAULT;
1404
+ const mockConfig = {
1405
+ getSessionId: () => 'test-session-id',
1406
+ getUsageStatisticsEnabled: () => true,
1407
+ getDebugMode: () => false,
1408
+ getApprovalMode: () => approvalMode,
1409
+ getAllowedTools: () => [],
1410
+ setApprovalMode: (mode) => {
1411
+ approvalMode = mode;
1412
+ },
1413
+ getShellExecutionConfig: () => ({
1414
+ terminalWidth: 90,
1415
+ terminalHeight: 30,
1416
+ }),
1417
+ storage: {
1418
+ getProjectTempDir: () => '/tmp',
1419
+ },
1420
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1421
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1422
+ getUseModelRouter: () => false,
1423
+ getGeminiClient: () => null, // No client needed for these tests
1424
+ isInteractive: () => true, // Required to prevent auto-denial of tool calls
1425
+ getIdeMode: () => false,
1426
+ getExperimentalZedIntegration: () => false,
1427
+ getChatRecordingService: () => undefined,
1428
+ };
1429
+ const testTool = new TestApprovalTool(mockConfig);
1430
+ const toolRegistry = {
1431
+ getTool: () => testTool,
1432
+ getFunctionDeclarations: () => [],
1433
+ getFunctionDeclarationsFiltered: () => [],
1434
+ registerTool: () => { },
1435
+ discoverAllTools: async () => { },
1436
+ discoverMcpTools: async () => { },
1437
+ discoverToolsForServer: async () => { },
1438
+ removeMcpToolsByServer: () => { },
1439
+ getAllTools: () => [],
1440
+ getToolsByServer: () => [],
1441
+ tools: new Map(),
1442
+ config: mockConfig,
1443
+ mcpClientManager: undefined,
1444
+ getToolByName: () => testTool,
1445
+ getToolByDisplayName: () => testTool,
1446
+ getTools: () => [],
1447
+ discoverTools: async () => { },
1448
+ discovery: {},
1449
+ };
1450
+ mockConfig.getToolRegistry = () => toolRegistry;
1451
+ const onAllToolCallsComplete = vi.fn();
1452
+ const onToolCallsUpdate = vi.fn();
1453
+ const pendingConfirmations = [];
1454
+ const scheduler = new CoreToolScheduler({
1455
+ config: mockConfig,
1456
+ onAllToolCallsComplete,
1457
+ onToolCallsUpdate: (toolCalls) => {
1458
+ onToolCallsUpdate(toolCalls);
1459
+ // Capture confirmation handlers for awaiting_approval tools
1460
+ toolCalls.forEach((call) => {
1461
+ if (call.status === 'awaiting_approval') {
1462
+ const waitingCall = call;
1463
+ if (waitingCall.confirmationDetails?.onConfirm) {
1464
+ const originalHandler = pendingConfirmations.find((h) => h === waitingCall.confirmationDetails.onConfirm);
1465
+ if (!originalHandler) {
1466
+ pendingConfirmations.push(waitingCall.confirmationDetails.onConfirm);
1467
+ }
1468
+ }
1469
+ }
1470
+ });
1471
+ },
1472
+ getPreferredEditor: () => 'vscode',
1473
+ onEditorClose: vi.fn(),
1474
+ });
1475
+ const abortController = new AbortController();
1476
+ // Schedule multiple tools that need confirmation
1477
+ const requests = [
1478
+ {
1479
+ callId: '1',
1480
+ name: 'testApprovalTool',
1481
+ args: { id: 'first' },
1482
+ isClientInitiated: false,
1483
+ prompt_id: 'prompt-1',
1484
+ },
1485
+ {
1486
+ callId: '2',
1487
+ name: 'testApprovalTool',
1488
+ args: { id: 'second' },
1489
+ isClientInitiated: false,
1490
+ prompt_id: 'prompt-2',
1491
+ },
1492
+ {
1493
+ callId: '3',
1494
+ name: 'testApprovalTool',
1495
+ args: { id: 'third' },
1496
+ isClientInitiated: false,
1497
+ prompt_id: 'prompt-3',
1498
+ },
1499
+ ];
1500
+ await scheduler.schedule(requests, abortController.signal);
1501
+ // Wait for all tools to be awaiting approval
1502
+ await vi.waitFor(() => {
1503
+ const calls = onToolCallsUpdate.mock.calls.at(-1)?.[0];
1504
+ expect(calls?.length).toBe(3);
1505
+ expect(calls?.every((call) => call.status === 'awaiting_approval')).toBe(true);
1506
+ });
1507
+ expect(pendingConfirmations.length).toBe(3);
1508
+ // Approve the first tool with ProceedAlways
1509
+ const firstConfirmation = pendingConfirmations[0];
1510
+ await firstConfirmation(ToolConfirmationOutcome.ProceedAlways);
1511
+ // Wait for all tools to be completed
1512
+ await vi.waitFor(() => {
1513
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1514
+ const completedCalls = onAllToolCallsComplete.mock.calls.at(-1)?.[0];
1515
+ expect(completedCalls?.length).toBe(3);
1516
+ expect(completedCalls?.every((call) => call.status === 'success')).toBe(true);
1517
+ });
1518
+ // Verify approval mode was changed
1519
+ expect(approvalMode).toBe(ApprovalMode.AUTO_EDIT);
1520
+ });
1521
+ });
1522
+ describe('CoreToolScheduler truncated output protection', () => {
1523
+ function createTruncationTestScheduler(tool, toolNames) {
1524
+ const onAllToolCallsComplete = vi.fn();
1525
+ const onToolCallsUpdate = vi.fn();
1526
+ const mockToolRegistry = {
1527
+ getTool: () => tool,
1528
+ getAllToolNames: () => toolNames,
1529
+ getFunctionDeclarations: () => [],
1530
+ tools: new Map(),
1531
+ };
1532
+ const mockConfig = {
1533
+ getSessionId: () => 'test-session-id',
1534
+ getUsageStatisticsEnabled: () => true,
1535
+ getDebugMode: () => false,
1536
+ getApprovalMode: () => ApprovalMode.AUTO_EDIT,
1537
+ getAllowedTools: () => [],
1538
+ getExcludeTools: () => undefined,
1539
+ getContentGeneratorConfig: () => ({
1540
+ model: 'test-model',
1541
+ authType: 'gemini',
1542
+ }),
1543
+ getShellExecutionConfig: () => ({
1544
+ terminalWidth: 90,
1545
+ terminalHeight: 30,
1546
+ }),
1547
+ storage: {
1548
+ getProjectTempDir: () => '/tmp',
1549
+ },
1550
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1551
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1552
+ getToolRegistry: () => mockToolRegistry,
1553
+ getUseModelRouter: () => false,
1554
+ getGeminiClient: () => null,
1555
+ getChatRecordingService: () => undefined,
1556
+ isInteractive: () => true,
1557
+ };
1558
+ const scheduler = new CoreToolScheduler({
1559
+ config: mockConfig,
1560
+ onAllToolCallsComplete,
1561
+ onToolCallsUpdate,
1562
+ getPreferredEditor: () => 'vscode',
1563
+ onEditorClose: vi.fn(),
1564
+ });
1565
+ return { scheduler, onAllToolCallsComplete };
1566
+ }
1567
+ it('should reject Kind.Edit tool calls when wasOutputTruncated is true', async () => {
1568
+ const declarativeTool = new TestApprovalTool({
1569
+ getApprovalMode: () => ApprovalMode.AUTO_EDIT,
1570
+ });
1571
+ const { scheduler, onAllToolCallsComplete } = createTruncationTestScheduler(declarativeTool, [TestApprovalTool.Name]);
1572
+ await scheduler.schedule([
1573
+ {
1574
+ callId: '1',
1575
+ name: TestApprovalTool.Name,
1576
+ args: { id: 'test-truncated' },
1577
+ isClientInitiated: false,
1578
+ prompt_id: 'prompt-id-truncated',
1579
+ wasOutputTruncated: true,
1580
+ },
1581
+ ], new AbortController().signal);
1582
+ await vi.waitFor(() => {
1583
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1584
+ });
1585
+ const completedCalls = onAllToolCallsComplete.mock
1586
+ .calls[0][0];
1587
+ expect(completedCalls).toHaveLength(1);
1588
+ const completedCall = completedCalls[0];
1589
+ expect(completedCall.status).toBe('error');
1590
+ if (completedCall.status === 'error') {
1591
+ const errorMessage = completedCall.response.error?.message;
1592
+ expect(errorMessage).toContain('truncated due to max_tokens limit');
1593
+ expect(errorMessage).toContain('rejected to prevent writing truncated content');
1594
+ }
1595
+ });
1596
+ it('should allow Kind.Edit tool calls when wasOutputTruncated is false', async () => {
1597
+ const declarativeTool = new TestApprovalTool({
1598
+ getApprovalMode: () => ApprovalMode.AUTO_EDIT,
1599
+ });
1600
+ const { scheduler, onAllToolCallsComplete } = createTruncationTestScheduler(declarativeTool, [TestApprovalTool.Name]);
1601
+ await scheduler.schedule([
1602
+ {
1603
+ callId: '1',
1604
+ name: TestApprovalTool.Name,
1605
+ args: { id: 'test-normal' },
1606
+ isClientInitiated: false,
1607
+ prompt_id: 'prompt-id-normal',
1608
+ wasOutputTruncated: false,
1609
+ },
1610
+ ], new AbortController().signal);
1611
+ await vi.waitFor(() => {
1612
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1613
+ });
1614
+ const completedCalls = onAllToolCallsComplete.mock
1615
+ .calls[0][0];
1616
+ expect(completedCalls).toHaveLength(1);
1617
+ // Should succeed (not error) since wasOutputTruncated is false
1618
+ expect(completedCalls[0].status).toBe('success');
1619
+ });
1620
+ it('should allow non-Edit tools when wasOutputTruncated is true', async () => {
1621
+ const mockTool = new MockTool({
1622
+ name: 'mockReadTool',
1623
+ execute: async () => ({
1624
+ llmContent: 'read result',
1625
+ returnDisplay: 'read result',
1626
+ }),
1627
+ });
1628
+ const { scheduler, onAllToolCallsComplete } = createTruncationTestScheduler(mockTool, ['mockReadTool']);
1629
+ await scheduler.schedule([
1630
+ {
1631
+ callId: '1',
1632
+ name: 'mockReadTool',
1633
+ args: {},
1634
+ isClientInitiated: false,
1635
+ prompt_id: 'prompt-id-read-truncated',
1636
+ wasOutputTruncated: true,
1637
+ },
1638
+ ], new AbortController().signal);
1639
+ await vi.waitFor(() => {
1640
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1641
+ });
1642
+ const completedCalls = onAllToolCallsComplete.mock
1643
+ .calls[0][0];
1644
+ expect(completedCalls).toHaveLength(1);
1645
+ // Non-Edit tools should still execute even when output was truncated
1646
+ expect(completedCalls[0].status).toBe('success');
1647
+ });
1648
+ });
1649
+ describe('CoreToolScheduler Sequential Execution', () => {
1650
+ it('should execute tool calls in a batch sequentially', async () => {
1651
+ // Arrange
1652
+ let firstCallFinished = false;
1653
+ const executeFn = vi
1654
+ .fn()
1655
+ .mockImplementation(async (args) => {
1656
+ if (args.call === 1) {
1657
+ // First call, wait for a bit to simulate work
1658
+ await new Promise((resolve) => setTimeout(resolve, 50));
1659
+ firstCallFinished = true;
1660
+ return { llmContent: 'First call done' };
1661
+ }
1662
+ if (args.call === 2) {
1663
+ // Second call, should only happen after the first is finished
1664
+ if (!firstCallFinished) {
1665
+ throw new Error('Second tool call started before the first one finished!');
1666
+ }
1667
+ return { llmContent: 'Second call done' };
1668
+ }
1669
+ return { llmContent: 'default' };
1670
+ });
1671
+ const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
1672
+ const declarativeTool = mockTool;
1673
+ const mockToolRegistry = {
1674
+ getTool: () => declarativeTool,
1675
+ getToolByName: () => declarativeTool,
1676
+ getFunctionDeclarations: () => [],
1677
+ tools: new Map(),
1678
+ discovery: {},
1679
+ registerTool: () => { },
1680
+ getToolByDisplayName: () => declarativeTool,
1681
+ getTools: () => [],
1682
+ discoverTools: async () => { },
1683
+ getAllTools: () => [],
1684
+ getToolsByServer: () => [],
1685
+ };
1686
+ const onAllToolCallsComplete = vi.fn();
1687
+ const onToolCallsUpdate = vi.fn();
1688
+ const mockConfig = {
1689
+ getSessionId: () => 'test-session-id',
1690
+ getUsageStatisticsEnabled: () => true,
1691
+ getDebugMode: () => false,
1692
+ getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
1693
+ getAllowedTools: () => [],
1694
+ getContentGeneratorConfig: () => ({
1695
+ model: 'test-model',
1696
+ authType: 'gemini',
1697
+ }),
1698
+ getShellExecutionConfig: () => ({
1699
+ terminalWidth: 90,
1700
+ terminalHeight: 30,
1701
+ }),
1702
+ storage: {
1703
+ getProjectTempDir: () => '/tmp',
1704
+ },
1705
+ getToolRegistry: () => mockToolRegistry,
1706
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1707
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1708
+ getUseModelRouter: () => false,
1709
+ getGeminiClient: () => null,
1710
+ getChatRecordingService: () => undefined,
1711
+ };
1712
+ const scheduler = new CoreToolScheduler({
1713
+ config: mockConfig,
1714
+ onAllToolCallsComplete,
1715
+ onToolCallsUpdate,
1716
+ getPreferredEditor: () => 'vscode',
1717
+ onEditorClose: vi.fn(),
1718
+ });
1719
+ const abortController = new AbortController();
1720
+ const requests = [
1721
+ {
1722
+ callId: '1',
1723
+ name: 'mockTool',
1724
+ args: { call: 1 },
1725
+ isClientInitiated: false,
1726
+ prompt_id: 'prompt-1',
1727
+ },
1728
+ {
1729
+ callId: '2',
1730
+ name: 'mockTool',
1731
+ args: { call: 2 },
1732
+ isClientInitiated: false,
1733
+ prompt_id: 'prompt-1',
1734
+ },
1735
+ ];
1736
+ // Act
1737
+ await scheduler.schedule(requests, abortController.signal);
1738
+ // Assert
1739
+ await vi.waitFor(() => {
1740
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1741
+ });
1742
+ // Check that execute was called twice
1743
+ expect(executeFn).toHaveBeenCalledTimes(2);
1744
+ // Check the order of calls
1745
+ const calls = executeFn.mock.calls;
1746
+ expect(calls[0][0]).toEqual({ call: 1 });
1747
+ expect(calls[1][0]).toEqual({ call: 2 });
1748
+ // The onAllToolCallsComplete should be called once with both results
1749
+ const completedCalls = onAllToolCallsComplete.mock
1750
+ .calls[0][0];
1751
+ expect(completedCalls).toHaveLength(2);
1752
+ expect(completedCalls[0].status).toBe('success');
1753
+ expect(completedCalls[1].status).toBe('success');
1754
+ });
1755
+ it('should cancel subsequent tools when the signal is aborted.', async () => {
1756
+ // Arrange
1757
+ const abortController = new AbortController();
1758
+ let secondCallStarted = false;
1759
+ const executeFn = vi
1760
+ .fn()
1761
+ .mockImplementation(async (args) => {
1762
+ if (args.call === 1) {
1763
+ return { llmContent: 'First call done' };
1764
+ }
1765
+ if (args.call === 2) {
1766
+ secondCallStarted = true;
1767
+ // This call will be cancelled while it's "running".
1768
+ await new Promise((resolve) => setTimeout(resolve, 100));
1769
+ // It should not return a value because it will be cancelled.
1770
+ return { llmContent: 'Second call should not complete' };
1771
+ }
1772
+ if (args.call === 3) {
1773
+ return { llmContent: 'Third call done' };
1774
+ }
1775
+ return { llmContent: 'default' };
1776
+ });
1777
+ const mockTool = new MockTool({ name: 'mockTool', execute: executeFn });
1778
+ const declarativeTool = mockTool;
1779
+ const mockToolRegistry = {
1780
+ getTool: () => declarativeTool,
1781
+ getToolByName: () => declarativeTool,
1782
+ getFunctionDeclarations: () => [],
1783
+ tools: new Map(),
1784
+ discovery: {},
1785
+ registerTool: () => { },
1786
+ getToolByDisplayName: () => declarativeTool,
1787
+ getTools: () => [],
1788
+ discoverTools: async () => { },
1789
+ getAllTools: () => [],
1790
+ getToolsByServer: () => [],
1791
+ };
1792
+ const onAllToolCallsComplete = vi.fn();
1793
+ const onToolCallsUpdate = vi.fn();
1794
+ const mockConfig = {
1795
+ getSessionId: () => 'test-session-id',
1796
+ getUsageStatisticsEnabled: () => true,
1797
+ getDebugMode: () => false,
1798
+ getApprovalMode: () => ApprovalMode.YOLO,
1799
+ getAllowedTools: () => [],
1800
+ getContentGeneratorConfig: () => ({
1801
+ model: 'test-model',
1802
+ authType: 'gemini',
1803
+ }),
1804
+ getShellExecutionConfig: () => ({
1805
+ terminalWidth: 90,
1806
+ terminalHeight: 30,
1807
+ }),
1808
+ storage: {
1809
+ getProjectTempDir: () => '/tmp',
1810
+ },
1811
+ getToolRegistry: () => mockToolRegistry,
1812
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1813
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1814
+ getUseModelRouter: () => false,
1815
+ getGeminiClient: () => null,
1816
+ getChatRecordingService: () => undefined,
1817
+ };
1818
+ const scheduler = new CoreToolScheduler({
1819
+ config: mockConfig,
1820
+ onAllToolCallsComplete,
1821
+ onToolCallsUpdate,
1822
+ getPreferredEditor: () => 'vscode',
1823
+ onEditorClose: vi.fn(),
1824
+ });
1825
+ const requests = [
1826
+ {
1827
+ callId: '1',
1828
+ name: 'mockTool',
1829
+ args: { call: 1 },
1830
+ isClientInitiated: false,
1831
+ prompt_id: 'prompt-1',
1832
+ },
1833
+ {
1834
+ callId: '2',
1835
+ name: 'mockTool',
1836
+ args: { call: 2 },
1837
+ isClientInitiated: false,
1838
+ prompt_id: 'prompt-1',
1839
+ },
1840
+ {
1841
+ callId: '3',
1842
+ name: 'mockTool',
1843
+ args: { call: 3 },
1844
+ isClientInitiated: false,
1845
+ prompt_id: 'prompt-1',
1846
+ },
1847
+ ];
1848
+ // Act
1849
+ const schedulePromise = scheduler.schedule(requests, abortController.signal);
1850
+ // Wait for the second call to start, then abort.
1851
+ await vi.waitFor(() => {
1852
+ expect(secondCallStarted).toBe(true);
1853
+ });
1854
+ abortController.abort();
1855
+ await schedulePromise;
1856
+ // Assert
1857
+ await vi.waitFor(() => {
1858
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
1859
+ });
1860
+ // Check that execute was called for all three tools initially
1861
+ expect(executeFn).toHaveBeenCalledTimes(3);
1862
+ expect(executeFn).toHaveBeenCalledWith({ call: 1 });
1863
+ expect(executeFn).toHaveBeenCalledWith({ call: 2 });
1864
+ expect(executeFn).toHaveBeenCalledWith({ call: 3 });
1865
+ const completedCalls = onAllToolCallsComplete.mock
1866
+ .calls[0][0];
1867
+ expect(completedCalls).toHaveLength(3);
1868
+ const call1 = completedCalls.find((c) => c.request.callId === '1');
1869
+ const call2 = completedCalls.find((c) => c.request.callId === '2');
1870
+ const call3 = completedCalls.find((c) => c.request.callId === '3');
1871
+ expect(call1?.status).toBe('success');
1872
+ expect(call2?.status).toBe('cancelled');
1873
+ expect(call3?.status).toBe('cancelled');
1874
+ });
1875
+ });
1876
+ describe('truncateAndSaveToFile', () => {
1877
+ const mockWriteFile = vi.mocked(fs.writeFile);
1878
+ const THRESHOLD = 40_000;
1879
+ const TRUNCATE_LINES = 1000;
1880
+ beforeEach(() => {
1881
+ vi.clearAllMocks();
1882
+ });
1883
+ it('should return content unchanged if below threshold', async () => {
1884
+ const content = 'Short content';
1885
+ const callId = 'test-call-id';
1886
+ const projectTempDir = '/tmp';
1887
+ const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
1888
+ expect(result).toEqual({ content });
1889
+ expect(mockWriteFile).not.toHaveBeenCalled();
1890
+ });
1891
+ it('should truncate content by lines when content has many lines', async () => {
1892
+ // Create content that exceeds 100,000 character threshold with many lines
1893
+ const lines = Array(2000).fill('x'.repeat(100)); // 100 chars per line * 2000 lines = 200,000 chars
1894
+ const content = lines.join('\n');
1895
+ const callId = 'test-call-id';
1896
+ const projectTempDir = '/tmp';
1897
+ mockWriteFile.mockResolvedValue(undefined);
1898
+ const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
1899
+ expect(result.outputFile).toBe(path.join(projectTempDir, `${callId}.output`));
1900
+ expect(mockWriteFile).toHaveBeenCalledWith(path.join(projectTempDir, `${callId}.output`), content);
1901
+ // Should contain the first and last lines with 1/5 head and 4/5 tail
1902
+ const head = Math.floor(TRUNCATE_LINES / 5);
1903
+ const beginning = lines.slice(0, head);
1904
+ const end = lines.slice(-(TRUNCATE_LINES - head));
1905
+ const expectedTruncated = beginning.join('\n') + '\n... [CONTENT TRUNCATED] ...\n' + end.join('\n');
1906
+ expect(result.content).toContain('Tool output was too large and has been truncated');
1907
+ expect(result.content).toContain('Truncated part of the output:');
1908
+ expect(result.content).toContain(expectedTruncated);
1909
+ });
1910
+ it('should wrap and truncate content when content has few but long lines', async () => {
1911
+ const content = 'a'.repeat(200_000); // A single very long line
1912
+ const callId = 'test-call-id';
1913
+ const projectTempDir = '/tmp';
1914
+ const wrapWidth = 120;
1915
+ mockWriteFile.mockResolvedValue(undefined);
1916
+ // Manually wrap the content to generate the expected file content
1917
+ const wrappedLines = [];
1918
+ for (let i = 0; i < content.length; i += wrapWidth) {
1919
+ wrappedLines.push(content.substring(i, i + wrapWidth));
1920
+ }
1921
+ const expectedFileContent = wrappedLines.join('\n');
1922
+ const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
1923
+ expect(result.outputFile).toBe(path.join(projectTempDir, `${callId}.output`));
1924
+ // Check that the file was written with the wrapped content
1925
+ expect(mockWriteFile).toHaveBeenCalledWith(path.join(projectTempDir, `${callId}.output`), expectedFileContent);
1926
+ // Should contain the first and last lines with 1/5 head and 4/5 tail of the wrapped content
1927
+ const head = Math.floor(TRUNCATE_LINES / 5);
1928
+ const beginning = wrappedLines.slice(0, head);
1929
+ const end = wrappedLines.slice(-(TRUNCATE_LINES - head));
1930
+ const expectedTruncated = beginning.join('\n') + '\n... [CONTENT TRUNCATED] ...\n' + end.join('\n');
1931
+ expect(result.content).toContain('Tool output was too large and has been truncated');
1932
+ expect(result.content).toContain('Truncated part of the output:');
1933
+ expect(result.content).toContain(expectedTruncated);
1934
+ });
1935
+ it('should handle file write errors gracefully', async () => {
1936
+ const content = 'a'.repeat(2_000_000);
1937
+ const callId = 'test-call-id';
1938
+ const projectTempDir = '/tmp';
1939
+ mockWriteFile.mockRejectedValue(new Error('File write failed'));
1940
+ const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
1941
+ expect(result.outputFile).toBeUndefined();
1942
+ expect(result.content).toContain('[Note: Could not save full output to file]');
1943
+ expect(mockWriteFile).toHaveBeenCalled();
1944
+ });
1945
+ it('should save to correct file path with call ID', async () => {
1946
+ const content = 'a'.repeat(200_000);
1947
+ const callId = 'unique-call-123';
1948
+ const projectTempDir = '/custom/temp/dir';
1949
+ const wrapWidth = 120;
1950
+ mockWriteFile.mockResolvedValue(undefined);
1951
+ // Manually wrap the content to generate the expected file content
1952
+ const wrappedLines = [];
1953
+ for (let i = 0; i < content.length; i += wrapWidth) {
1954
+ wrappedLines.push(content.substring(i, i + wrapWidth));
1955
+ }
1956
+ const expectedFileContent = wrappedLines.join('\n');
1957
+ const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
1958
+ const expectedPath = path.join(projectTempDir, `${callId}.output`);
1959
+ expect(result.outputFile).toBe(expectedPath);
1960
+ expect(mockWriteFile).toHaveBeenCalledWith(expectedPath, expectedFileContent);
1961
+ });
1962
+ it('should include helpful instructions in truncated message', async () => {
1963
+ const content = 'a'.repeat(2_000_000);
1964
+ const callId = 'test-call-id';
1965
+ const projectTempDir = '/tmp';
1966
+ mockWriteFile.mockResolvedValue(undefined);
1967
+ const result = await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
1968
+ expect(result.content).toContain('Tool output was too large and has been truncated');
1969
+ expect(result.content).toContain('The full output has been saved to:');
1970
+ expect(result.content).toContain('To read the complete output, use the read_file tool with the absolute file path above');
1971
+ expect(result.content).toContain('The truncated output below shows the beginning and end of the content');
1972
+ });
1973
+ it('should sanitize callId to prevent path traversal', async () => {
1974
+ const content = 'a'.repeat(200_000);
1975
+ const callId = '../../../../../etc/passwd';
1976
+ const projectTempDir = '/tmp/safe_dir';
1977
+ const wrapWidth = 120;
1978
+ mockWriteFile.mockResolvedValue(undefined);
1979
+ // Manually wrap the content to generate the expected file content
1980
+ const wrappedLines = [];
1981
+ for (let i = 0; i < content.length; i += wrapWidth) {
1982
+ wrappedLines.push(content.substring(i, i + wrapWidth));
1983
+ }
1984
+ const expectedFileContent = wrappedLines.join('\n');
1985
+ await truncateAndSaveToFile(content, callId, projectTempDir, THRESHOLD, TRUNCATE_LINES);
1986
+ const expectedPath = path.join(projectTempDir, 'passwd.output');
1987
+ expect(mockWriteFile).toHaveBeenCalledWith(expectedPath, expectedFileContent);
1988
+ });
1989
+ });
1990
+ describe('CoreToolScheduler plan mode with ask_user_question', () => {
1991
+ function createAskUserQuestionMockTool() {
1992
+ let wasAnswered = false;
1993
+ let userAnswers = {};
1994
+ return new MockTool({
1995
+ name: 'ask_user_question',
1996
+ shouldConfirmExecute: async () => ({
1997
+ type: 'ask_user_question',
1998
+ title: 'Please answer the following question(s):',
1999
+ questions: [
2000
+ {
2001
+ question: 'Which approach do you prefer?',
2002
+ header: 'Approach',
2003
+ options: [
2004
+ { label: 'Option A', description: 'First approach' },
2005
+ { label: 'Option B', description: 'Second approach' },
2006
+ ],
2007
+ multiSelect: false,
2008
+ },
2009
+ ],
2010
+ onConfirm: async (outcome, payload) => {
2011
+ if (outcome === ToolConfirmationOutcome.ProceedOnce ||
2012
+ outcome === ToolConfirmationOutcome.ProceedAlways) {
2013
+ wasAnswered = true;
2014
+ userAnswers = payload?.answers ?? {};
2015
+ }
2016
+ else {
2017
+ wasAnswered = false;
2018
+ }
2019
+ },
2020
+ }),
2021
+ execute: async () => {
2022
+ if (!wasAnswered) {
2023
+ return {
2024
+ llmContent: 'User declined to answer the questions.',
2025
+ returnDisplay: 'User declined to answer the questions.',
2026
+ };
2027
+ }
2028
+ const answersContent = Object.entries(userAnswers)
2029
+ .map(([key, value]) => `**Question ${key}**: ${value}`)
2030
+ .join('\n');
2031
+ return {
2032
+ llmContent: `User has provided the following answers:\n\n${answersContent}`,
2033
+ returnDisplay: `User has provided the following answers:\n\n${answersContent}`,
2034
+ };
2035
+ },
2036
+ });
2037
+ }
2038
+ function createPlanModeScheduler(tool, onAllToolCallsComplete, onToolCallsUpdate) {
2039
+ const mockToolRegistry = {
2040
+ getTool: () => tool,
2041
+ getToolByName: () => tool,
2042
+ getFunctionDeclarations: () => [],
2043
+ tools: new Map(),
2044
+ discovery: {},
2045
+ registerTool: () => { },
2046
+ getToolByDisplayName: () => tool,
2047
+ getTools: () => [],
2048
+ discoverTools: async () => { },
2049
+ getAllTools: () => [],
2050
+ getToolsByServer: () => [],
2051
+ };
2052
+ const mockConfig = {
2053
+ getSessionId: () => 'test-session-id',
2054
+ getUsageStatisticsEnabled: () => true,
2055
+ getDebugMode: () => false,
2056
+ getApprovalMode: () => ApprovalMode.PLAN,
2057
+ getAllowedTools: () => [],
2058
+ getContentGeneratorConfig: () => ({
2059
+ model: 'test-model',
2060
+ authType: 'gemini',
2061
+ }),
2062
+ getShellExecutionConfig: () => ({
2063
+ terminalWidth: 90,
2064
+ terminalHeight: 30,
2065
+ }),
2066
+ storage: {
2067
+ getProjectTempDir: () => '/tmp',
2068
+ },
2069
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
2070
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
2071
+ getToolRegistry: () => mockToolRegistry,
2072
+ getUseModelRouter: () => false,
2073
+ getGeminiClient: () => null,
2074
+ isInteractive: () => true,
2075
+ getIdeMode: () => false,
2076
+ getExperimentalZedIntegration: () => false,
2077
+ getChatRecordingService: () => undefined,
2078
+ };
2079
+ return new CoreToolScheduler({
2080
+ config: mockConfig,
2081
+ onAllToolCallsComplete,
2082
+ onToolCallsUpdate,
2083
+ getPreferredEditor: () => 'vscode',
2084
+ onEditorClose: vi.fn(),
2085
+ });
2086
+ }
2087
+ it('should enter awaiting_approval for ask_user_question in plan mode', async () => {
2088
+ const mockTool = createAskUserQuestionMockTool();
2089
+ const onAllToolCallsComplete = vi.fn();
2090
+ const onToolCallsUpdate = vi.fn();
2091
+ const scheduler = createPlanModeScheduler(mockTool, onAllToolCallsComplete, onToolCallsUpdate);
2092
+ const abortController = new AbortController();
2093
+ const request = {
2094
+ callId: '1',
2095
+ name: 'ask_user_question',
2096
+ args: {
2097
+ questions: [
2098
+ {
2099
+ question: 'Which approach?',
2100
+ header: 'Approach',
2101
+ options: [
2102
+ { label: 'A', description: 'First' },
2103
+ { label: 'B', description: 'Second' },
2104
+ ],
2105
+ multiSelect: false,
2106
+ },
2107
+ ],
2108
+ },
2109
+ isClientInitiated: false,
2110
+ prompt_id: 'prompt-plan-ask',
2111
+ };
2112
+ await scheduler.schedule([request], abortController.signal);
2113
+ // Should enter awaiting_approval, NOT be directly scheduled
2114
+ const awaitingCall = await waitForStatus(onToolCallsUpdate, 'awaiting_approval');
2115
+ expect(awaitingCall).toBeDefined();
2116
+ expect(awaitingCall.status).toBe('awaiting_approval');
2117
+ });
2118
+ it('should execute successfully when user answers in plan mode', async () => {
2119
+ const mockTool = createAskUserQuestionMockTool();
2120
+ const onAllToolCallsComplete = vi.fn();
2121
+ const onToolCallsUpdate = vi.fn();
2122
+ const scheduler = createPlanModeScheduler(mockTool, onAllToolCallsComplete, onToolCallsUpdate);
2123
+ const abortController = new AbortController();
2124
+ const request = {
2125
+ callId: '1',
2126
+ name: 'ask_user_question',
2127
+ args: {
2128
+ questions: [
2129
+ {
2130
+ question: 'Which approach?',
2131
+ header: 'Approach',
2132
+ options: [
2133
+ { label: 'A', description: 'First' },
2134
+ { label: 'B', description: 'Second' },
2135
+ ],
2136
+ multiSelect: false,
2137
+ },
2138
+ ],
2139
+ },
2140
+ isClientInitiated: false,
2141
+ prompt_id: 'prompt-plan-ask-answer',
2142
+ };
2143
+ await scheduler.schedule([request], abortController.signal);
2144
+ const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
2145
+ // Simulate user answering the question
2146
+ await awaitingCall.confirmationDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce, { answers: { '0': 'Option A' } });
2147
+ await vi.waitFor(() => {
2148
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
2149
+ });
2150
+ const completedCalls = onAllToolCallsComplete.mock
2151
+ .calls[0][0];
2152
+ expect(completedCalls[0].status).toBe('success');
2153
+ if (completedCalls[0].status === 'success') {
2154
+ expect(completedCalls[0].response.resultDisplay).toContain('User has provided the following answers');
2155
+ }
2156
+ });
2157
+ it('should block non-ask_user_question tools that need confirmation in plan mode', async () => {
2158
+ const editTool = new MockTool({
2159
+ name: 'write_file',
2160
+ shouldConfirmExecute: MOCK_TOOL_SHOULD_CONFIRM_EXECUTE,
2161
+ });
2162
+ const onAllToolCallsComplete = vi.fn();
2163
+ const onToolCallsUpdate = vi.fn();
2164
+ const scheduler = createPlanModeScheduler(editTool, onAllToolCallsComplete, onToolCallsUpdate);
2165
+ const abortController = new AbortController();
2166
+ const request = {
2167
+ callId: '1',
2168
+ name: 'write_file',
2169
+ args: {},
2170
+ isClientInitiated: false,
2171
+ prompt_id: 'prompt-plan-blocked',
2172
+ };
2173
+ await scheduler.schedule([request], abortController.signal);
2174
+ await vi.waitFor(() => {
2175
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
2176
+ });
2177
+ const completedCalls = onAllToolCallsComplete.mock
2178
+ .calls[0][0];
2179
+ expect(completedCalls[0].status).toBe('error');
2180
+ if (completedCalls[0].status === 'error') {
2181
+ expect(completedCalls[0].response.resultDisplay).toBe('Plan mode blocked a non-read-only tool call.');
2182
+ }
2183
+ });
2184
+ it('should handle user cancellation of ask_user_question in plan mode', async () => {
2185
+ const mockTool = createAskUserQuestionMockTool();
2186
+ const onAllToolCallsComplete = vi.fn();
2187
+ const onToolCallsUpdate = vi.fn();
2188
+ const scheduler = createPlanModeScheduler(mockTool, onAllToolCallsComplete, onToolCallsUpdate);
2189
+ const abortController = new AbortController();
2190
+ const request = {
2191
+ callId: '1',
2192
+ name: 'ask_user_question',
2193
+ args: {
2194
+ questions: [
2195
+ {
2196
+ question: 'Which approach?',
2197
+ header: 'Approach',
2198
+ options: [
2199
+ { label: 'A', description: 'First' },
2200
+ { label: 'B', description: 'Second' },
2201
+ ],
2202
+ multiSelect: false,
2203
+ },
2204
+ ],
2205
+ },
2206
+ isClientInitiated: false,
2207
+ prompt_id: 'prompt-plan-ask-cancel',
2208
+ };
2209
+ await scheduler.schedule([request], abortController.signal);
2210
+ const awaitingCall = (await waitForStatus(onToolCallsUpdate, 'awaiting_approval'));
2211
+ // Simulate user cancelling
2212
+ await awaitingCall.confirmationDetails.onConfirm(ToolConfirmationOutcome.Cancel);
2213
+ await vi.waitFor(() => {
2214
+ expect(onAllToolCallsComplete).toHaveBeenCalled();
2215
+ });
2216
+ const completedCalls = onAllToolCallsComplete.mock
2217
+ .calls[0][0];
2218
+ expect(completedCalls[0].status).toBe('cancelled');
2219
+ });
2220
+ });
2221
+ //# sourceMappingURL=coreToolScheduler.test.js.map