@office-ai/aioncli-core 0.8.1 → 0.18.5

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 (778) hide show
  1. package/dist/index.d.ts +8 -2
  2. package/dist/index.js +7 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/agents/codebase-investigator.d.ts +36 -1
  5. package/dist/src/agents/codebase-investigator.js +93 -34
  6. package/dist/src/agents/codebase-investigator.js.map +1 -1
  7. package/dist/src/agents/codebase-investigator.test.d.ts +6 -0
  8. package/dist/src/agents/codebase-investigator.test.js +35 -0
  9. package/dist/src/agents/codebase-investigator.test.js.map +1 -0
  10. package/dist/src/agents/executor.d.ts +37 -11
  11. package/dist/src/agents/executor.js +512 -150
  12. package/dist/src/agents/executor.js.map +1 -1
  13. package/dist/src/agents/executor.test.js +1188 -245
  14. package/dist/src/agents/executor.test.js.map +1 -1
  15. package/dist/src/agents/invocation.d.ts +5 -2
  16. package/dist/src/agents/invocation.js +4 -2
  17. package/dist/src/agents/invocation.js.map +1 -1
  18. package/dist/src/agents/invocation.test.js +9 -0
  19. package/dist/src/agents/invocation.test.js.map +1 -1
  20. package/dist/src/agents/registry.d.ts +6 -1
  21. package/dist/src/agents/registry.js +51 -4
  22. package/dist/src/agents/registry.js.map +1 -1
  23. package/dist/src/agents/registry.test.js +30 -16
  24. package/dist/src/agents/registry.test.js.map +1 -1
  25. package/dist/src/agents/subagent-tool-wrapper.d.ts +3 -1
  26. package/dist/src/agents/subagent-tool-wrapper.js +4 -3
  27. package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
  28. package/dist/src/agents/subagent-tool-wrapper.test.js +9 -4
  29. package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
  30. package/dist/src/agents/types.d.ts +37 -7
  31. package/dist/src/agents/types.js +2 -0
  32. package/dist/src/agents/types.js.map +1 -1
  33. package/dist/src/code_assist/codeAssist.js +1 -1
  34. package/dist/src/code_assist/codeAssist.test.d.ts +6 -0
  35. package/dist/src/code_assist/codeAssist.test.js +99 -0
  36. package/dist/src/code_assist/codeAssist.test.js.map +1 -0
  37. package/dist/src/code_assist/converter.d.ts +1 -0
  38. package/dist/src/code_assist/converter.js +1 -0
  39. package/dist/src/code_assist/converter.js.map +1 -1
  40. package/dist/src/code_assist/converter.test.js +19 -0
  41. package/dist/src/code_assist/converter.test.js.map +1 -1
  42. package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
  43. package/dist/src/code_assist/experiments/client_metadata.js +50 -0
  44. package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
  45. package/dist/src/code_assist/experiments/client_metadata.test.d.ts +6 -0
  46. package/dist/src/code_assist/experiments/client_metadata.test.js +99 -0
  47. package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
  48. package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
  49. package/dist/src/code_assist/experiments/experiments.js +36 -0
  50. package/dist/src/code_assist/experiments/experiments.js.map +1 -0
  51. package/dist/src/code_assist/experiments/experiments.test.d.ts +6 -0
  52. package/dist/src/code_assist/experiments/experiments.test.js +92 -0
  53. package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
  54. package/dist/src/code_assist/experiments/flagNames.d.ts +13 -0
  55. package/dist/src/code_assist/experiments/flagNames.js +13 -0
  56. package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
  57. package/dist/src/code_assist/experiments/types.d.ts +35 -0
  58. package/dist/src/code_assist/experiments/types.js +7 -0
  59. package/dist/src/code_assist/experiments/types.js.map +1 -0
  60. package/dist/src/code_assist/oauth-credential-storage.js +6 -5
  61. package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
  62. package/dist/src/code_assist/oauth-credential-storage.test.js +65 -3
  63. package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -1
  64. package/dist/src/code_assist/oauth2.d.ts +2 -2
  65. package/dist/src/code_assist/oauth2.js +161 -93
  66. package/dist/src/code_assist/oauth2.js.map +1 -1
  67. package/dist/src/code_assist/oauth2.test.js +103 -57
  68. package/dist/src/code_assist/oauth2.test.js.map +1 -1
  69. package/dist/src/code_assist/server.d.ts +6 -4
  70. package/dist/src/code_assist/server.js +16 -8
  71. package/dist/src/code_assist/server.js.map +1 -1
  72. package/dist/src/code_assist/server.test.js +126 -28
  73. package/dist/src/code_assist/server.test.js.map +1 -1
  74. package/dist/src/code_assist/setup.d.ts +2 -2
  75. package/dist/src/code_assist/setup.js +4 -2
  76. package/dist/src/code_assist/setup.js.map +1 -1
  77. package/dist/src/code_assist/types.d.ts +1 -1
  78. package/dist/src/code_assist/types.js.map +1 -1
  79. package/dist/src/commands/extensions.d.ts +7 -0
  80. package/dist/src/commands/extensions.js +9 -0
  81. package/dist/src/commands/extensions.js.map +1 -0
  82. package/dist/src/commands/extensions.test.d.ts +6 -0
  83. package/dist/src/commands/extensions.test.js +19 -0
  84. package/dist/src/commands/extensions.test.js.map +1 -0
  85. package/dist/src/config/config.d.ts +169 -43
  86. package/dist/src/config/config.js +418 -79
  87. package/dist/src/config/config.js.map +1 -1
  88. package/dist/src/config/config.test.js +684 -49
  89. package/dist/src/config/config.test.js.map +1 -1
  90. package/dist/src/config/defaultModelConfigs.d.ts +7 -0
  91. package/dist/src/config/defaultModelConfigs.js +185 -0
  92. package/dist/src/config/defaultModelConfigs.js.map +1 -0
  93. package/dist/src/config/models.d.ts +23 -2
  94. package/dist/src/config/models.js +50 -7
  95. package/dist/src/config/models.js.map +1 -1
  96. package/dist/src/config/models.test.js +71 -10
  97. package/dist/src/config/models.test.js.map +1 -1
  98. package/dist/src/config/storage.d.ts +3 -1
  99. package/dist/src/config/storage.js +22 -2
  100. package/dist/src/config/storage.js.map +1 -1
  101. package/dist/src/config/storage.test.js +7 -6
  102. package/dist/src/config/storage.test.js.map +1 -1
  103. package/dist/src/confirmation-bus/message-bus.d.ts +3 -2
  104. package/dist/src/confirmation-bus/message-bus.js +9 -3
  105. package/dist/src/confirmation-bus/message-bus.js.map +1 -1
  106. package/dist/src/confirmation-bus/message-bus.test.js +30 -24
  107. package/dist/src/confirmation-bus/message-bus.test.js.map +1 -1
  108. package/dist/src/confirmation-bus/types.d.ts +13 -2
  109. package/dist/src/confirmation-bus/types.js +1 -0
  110. package/dist/src/confirmation-bus/types.js.map +1 -1
  111. package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
  112. package/dist/src/core/apiKeyCredentialStorage.js +64 -0
  113. package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
  114. package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
  115. package/dist/src/core/apiKeyCredentialStorage.test.js +71 -0
  116. package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
  117. package/dist/src/core/baseLlmClient.d.ts +4 -8
  118. package/dist/src/core/baseLlmClient.js +6 -11
  119. package/dist/src/core/baseLlmClient.js.map +1 -1
  120. package/dist/src/core/baseLlmClient.test.js +22 -27
  121. package/dist/src/core/baseLlmClient.test.js.map +1 -1
  122. package/dist/src/core/client.d.ts +12 -19
  123. package/dist/src/core/client.js +104 -206
  124. package/dist/src/core/client.js.map +1 -1
  125. package/dist/src/core/client.test.js +329 -452
  126. package/dist/src/core/client.test.js.map +1 -1
  127. package/dist/src/core/contentGenerator.d.ts +3 -2
  128. package/dist/src/core/contentGenerator.js +56 -41
  129. package/dist/src/core/contentGenerator.js.map +1 -1
  130. package/dist/src/core/contentGenerator.test.js +49 -1
  131. package/dist/src/core/contentGenerator.test.js.map +1 -1
  132. package/dist/src/core/coreToolScheduler.d.ts +8 -4
  133. package/dist/src/core/coreToolScheduler.js +348 -179
  134. package/dist/src/core/coreToolScheduler.js.map +1 -1
  135. package/dist/src/core/coreToolScheduler.test.js +575 -219
  136. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  137. package/dist/src/core/fakeContentGenerator.d.ts +33 -0
  138. package/dist/src/core/fakeContentGenerator.js +58 -0
  139. package/dist/src/core/fakeContentGenerator.js.map +1 -0
  140. package/dist/src/core/fakeContentGenerator.test.d.ts +6 -0
  141. package/dist/src/core/fakeContentGenerator.test.js +127 -0
  142. package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
  143. package/dist/src/core/geminiChat.d.ts +23 -18
  144. package/dist/src/core/geminiChat.js +186 -108
  145. package/dist/src/core/geminiChat.js.map +1 -1
  146. package/dist/src/core/geminiChat.test.js +581 -270
  147. package/dist/src/core/geminiChat.test.js.map +1 -1
  148. package/dist/src/core/logger.d.ts +7 -2
  149. package/dist/src/core/logger.js +35 -27
  150. package/dist/src/core/logger.js.map +1 -1
  151. package/dist/src/core/logger.test.js +45 -29
  152. package/dist/src/core/logger.test.js.map +1 -1
  153. package/dist/src/core/loggingContentGenerator.d.ts +1 -0
  154. package/dist/src/core/loggingContentGenerator.js +113 -33
  155. package/dist/src/core/loggingContentGenerator.js.map +1 -1
  156. package/dist/src/core/loggingContentGenerator.test.d.ts +6 -0
  157. package/dist/src/core/loggingContentGenerator.test.js +180 -0
  158. package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
  159. package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -2
  160. package/dist/src/core/nonInteractiveToolExecutor.js +12 -7
  161. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  162. package/dist/src/core/nonInteractiveToolExecutor.test.js +12 -8
  163. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  164. package/dist/src/core/openaiContentGenerator.d.ts +15 -1
  165. package/dist/src/core/openaiContentGenerator.js +139 -22
  166. package/dist/src/core/openaiContentGenerator.js.map +1 -1
  167. package/dist/src/core/prompts.d.ts +2 -1
  168. package/dist/src/core/prompts.js +135 -154
  169. package/dist/src/core/prompts.js.map +1 -1
  170. package/dist/src/core/prompts.test.js +128 -189
  171. package/dist/src/core/prompts.test.js.map +1 -1
  172. package/dist/src/core/recordingContentGenerator.d.ts +18 -0
  173. package/dist/src/core/recordingContentGenerator.js +77 -0
  174. package/dist/src/core/recordingContentGenerator.js.map +1 -0
  175. package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
  176. package/dist/src/core/recordingContentGenerator.test.js +101 -0
  177. package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
  178. package/dist/src/core/tokenLimits.test.d.ts +6 -0
  179. package/dist/src/core/tokenLimits.test.js +26 -0
  180. package/dist/src/core/tokenLimits.test.js.map +1 -0
  181. package/dist/src/core/turn.d.ts +23 -3
  182. package/dist/src/core/turn.js +18 -9
  183. package/dist/src/core/turn.js.map +1 -1
  184. package/dist/src/core/turn.test.js +98 -104
  185. package/dist/src/core/turn.test.js.map +1 -1
  186. package/dist/src/fallback/handler.js +60 -8
  187. package/dist/src/fallback/handler.js.map +1 -1
  188. package/dist/src/fallback/handler.test.js +132 -17
  189. package/dist/src/fallback/handler.test.js.map +1 -1
  190. package/dist/src/fallback/types.d.ts +1 -1
  191. package/dist/src/generated/git-commit.d.ts +2 -2
  192. package/dist/src/generated/git-commit.js +2 -2
  193. package/dist/src/generated/git-commit.js.map +1 -1
  194. package/dist/src/hooks/hookAggregator.d.ts +68 -0
  195. package/dist/src/hooks/hookAggregator.js +262 -0
  196. package/dist/src/hooks/hookAggregator.js.map +1 -0
  197. package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
  198. package/dist/src/hooks/hookAggregator.test.js +387 -0
  199. package/dist/src/hooks/hookAggregator.test.js.map +1 -0
  200. package/dist/src/hooks/hookPlanner.d.ts +46 -0
  201. package/dist/src/hooks/hookPlanner.js +108 -0
  202. package/dist/src/hooks/hookPlanner.js.map +1 -0
  203. package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
  204. package/dist/src/hooks/hookPlanner.test.js +255 -0
  205. package/dist/src/hooks/hookPlanner.test.js.map +1 -0
  206. package/dist/src/hooks/hookRegistry.d.ts +87 -0
  207. package/dist/src/hooks/hookRegistry.js +198 -0
  208. package/dist/src/hooks/hookRegistry.js.map +1 -0
  209. package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
  210. package/dist/src/hooks/hookRegistry.test.js +341 -0
  211. package/dist/src/hooks/hookRegistry.test.js.map +1 -0
  212. package/dist/src/hooks/hookRunner.d.ts +42 -0
  213. package/dist/src/hooks/hookRunner.js +272 -0
  214. package/dist/src/hooks/hookRunner.js.map +1 -0
  215. package/dist/src/hooks/hookRunner.test.d.ts +6 -0
  216. package/dist/src/hooks/hookRunner.test.js +468 -0
  217. package/dist/src/hooks/hookRunner.test.js.map +1 -0
  218. package/dist/src/hooks/hookTranslator.d.ts +113 -0
  219. package/dist/src/hooks/hookTranslator.js +232 -0
  220. package/dist/src/hooks/hookTranslator.js.map +1 -0
  221. package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
  222. package/dist/src/hooks/hookTranslator.test.js +192 -0
  223. package/dist/src/hooks/hookTranslator.test.js.map +1 -0
  224. package/dist/src/hooks/types.d.ts +384 -0
  225. package/dist/src/hooks/types.js +284 -0
  226. package/dist/src/hooks/types.js.map +1 -0
  227. package/dist/src/hooks/types.test.d.ts +6 -0
  228. package/dist/src/hooks/types.test.js +313 -0
  229. package/dist/src/hooks/types.test.js.map +1 -0
  230. package/dist/src/ide/detect-ide.d.ts +4 -0
  231. package/dist/src/ide/detect-ide.js +6 -1
  232. package/dist/src/ide/detect-ide.js.map +1 -1
  233. package/dist/src/ide/detect-ide.test.js +16 -0
  234. package/dist/src/ide/detect-ide.test.js.map +1 -1
  235. package/dist/src/ide/ide-client.d.ts +3 -1
  236. package/dist/src/ide/ide-client.js +12 -10
  237. package/dist/src/ide/ide-client.js.map +1 -1
  238. package/dist/src/ide/ide-client.test.js +163 -4
  239. package/dist/src/ide/ide-client.test.js.map +1 -1
  240. package/dist/src/ide/ide-installer.js +66 -21
  241. package/dist/src/ide/ide-installer.js.map +1 -1
  242. package/dist/src/ide/ide-installer.test.js +54 -1
  243. package/dist/src/ide/ide-installer.test.js.map +1 -1
  244. package/dist/src/ide/process-utils.js +85 -75
  245. package/dist/src/ide/process-utils.js.map +1 -1
  246. package/dist/src/ide/process-utils.test.js +83 -90
  247. package/dist/src/ide/process-utils.test.js.map +1 -1
  248. package/dist/src/ide/types.d.ts +5 -5
  249. package/dist/src/ide/types.js +1 -1
  250. package/dist/src/index.d.ts +21 -0
  251. package/dist/src/index.js +24 -0
  252. package/dist/src/index.js.map +1 -1
  253. package/dist/src/mcp/google-auth-provider.d.ts +2 -0
  254. package/dist/src/mcp/google-auth-provider.js +21 -3
  255. package/dist/src/mcp/google-auth-provider.js.map +1 -1
  256. package/dist/src/mcp/google-auth-provider.test.js +42 -9
  257. package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
  258. package/dist/src/mcp/oauth-provider.d.ts +8 -5
  259. package/dist/src/mcp/oauth-provider.js +140 -55
  260. package/dist/src/mcp/oauth-provider.js.map +1 -1
  261. package/dist/src/mcp/oauth-provider.test.js +369 -2
  262. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  263. package/dist/src/mcp/oauth-token-storage.js +5 -4
  264. package/dist/src/mcp/oauth-token-storage.js.map +1 -1
  265. package/dist/src/mcp/oauth-token-storage.test.js +17 -11
  266. package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
  267. package/dist/src/mcp/oauth-utils.d.ts +7 -0
  268. package/dist/src/mcp/oauth-utils.js +28 -8
  269. package/dist/src/mcp/oauth-utils.js.map +1 -1
  270. package/dist/src/mcp/oauth-utils.test.js +45 -2
  271. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  272. package/dist/src/mcp/sa-impersonation-provider.d.ts +0 -6
  273. package/dist/src/mcp/sa-impersonation-provider.js +6 -23
  274. package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
  275. package/dist/src/mcp/token-storage/base-token-storage.test.js +75 -84
  276. package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -1
  277. package/dist/src/mcp/token-storage/file-token-storage.js +3 -2
  278. package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
  279. package/dist/src/mcp/token-storage/file-token-storage.test.js +11 -8
  280. package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
  281. package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +6 -2
  282. package/dist/src/mcp/token-storage/keychain-token-storage.js +63 -7
  283. package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
  284. package/dist/src/mcp/token-storage/keychain-token-storage.test.js +54 -3
  285. package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -1
  286. package/dist/src/mcp/token-storage/types.d.ts +6 -0
  287. package/dist/src/mcp/token-storage/types.js.map +1 -1
  288. package/dist/src/output/stream-json-formatter.d.ts +32 -0
  289. package/dist/src/output/stream-json-formatter.js +52 -0
  290. package/dist/src/output/stream-json-formatter.js.map +1 -0
  291. package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
  292. package/dist/src/output/stream-json-formatter.test.js +479 -0
  293. package/dist/src/output/stream-json-formatter.test.js.map +1 -0
  294. package/dist/src/output/types.d.ts +63 -1
  295. package/dist/src/output/types.js +11 -0
  296. package/dist/src/output/types.js.map +1 -1
  297. package/dist/src/policy/config.d.ts +31 -0
  298. package/dist/src/policy/config.js +199 -0
  299. package/dist/src/policy/config.js.map +1 -0
  300. package/dist/src/policy/config.test.d.ts +6 -0
  301. package/dist/src/policy/config.test.js +538 -0
  302. package/dist/src/policy/config.test.js.map +1 -0
  303. package/dist/src/policy/index.d.ts +2 -0
  304. package/dist/src/policy/index.js +2 -0
  305. package/dist/src/policy/index.js.map +1 -1
  306. package/dist/src/policy/policies/discovered.toml +8 -0
  307. package/dist/src/policy/policies/read-only.toml +56 -0
  308. package/dist/src/policy/policies/write.toml +73 -0
  309. package/dist/src/policy/policies/yolo.toml +31 -0
  310. package/dist/src/policy/policy-engine.d.ts +12 -3
  311. package/dist/src/policy/policy-engine.js +74 -8
  312. package/dist/src/policy/policy-engine.js.map +1 -1
  313. package/dist/src/policy/policy-engine.test.js +460 -76
  314. package/dist/src/policy/policy-engine.test.js.map +1 -1
  315. package/dist/src/policy/toml-loader.d.ts +47 -0
  316. package/dist/src/policy/toml-loader.js +411 -0
  317. package/dist/src/policy/toml-loader.js.map +1 -0
  318. package/dist/src/policy/toml-loader.test.d.ts +6 -0
  319. package/dist/src/policy/toml-loader.test.js +376 -0
  320. package/dist/src/policy/toml-loader.test.js.map +1 -0
  321. package/dist/src/policy/types.d.ts +83 -0
  322. package/dist/src/policy/types.js +10 -0
  323. package/dist/src/policy/types.js.map +1 -1
  324. package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
  325. package/dist/src/prompts/mcp-prompts.test.js +39 -0
  326. package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
  327. package/dist/src/prompts/prompt-registry.js +2 -1
  328. package/dist/src/prompts/prompt-registry.js.map +1 -1
  329. package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
  330. package/dist/src/prompts/prompt-registry.test.js +96 -0
  331. package/dist/src/prompts/prompt-registry.test.js.map +1 -0
  332. package/dist/src/routing/modelRouterService.js +15 -0
  333. package/dist/src/routing/modelRouterService.js.map +1 -1
  334. package/dist/src/routing/modelRouterService.test.js +62 -0
  335. package/dist/src/routing/modelRouterService.test.js.map +1 -1
  336. package/dist/src/routing/strategies/classifierStrategy.d.ts +1 -1
  337. package/dist/src/routing/strategies/classifierStrategy.js +9 -16
  338. package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
  339. package/dist/src/routing/strategies/classifierStrategy.test.js +17 -13
  340. package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
  341. package/dist/src/routing/strategies/fallbackStrategy.js +1 -1
  342. package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
  343. package/dist/src/routing/strategies/fallbackStrategy.test.js +4 -0
  344. package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
  345. package/dist/src/routing/strategies/overrideStrategy.js +2 -2
  346. package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
  347. package/dist/src/routing/strategies/overrideStrategy.test.js +3 -0
  348. package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
  349. package/dist/src/safety/built-in.d.ts +21 -0
  350. package/dist/src/safety/built-in.js +106 -0
  351. package/dist/src/safety/built-in.js.map +1 -0
  352. package/dist/src/safety/built-in.test.d.ts +6 -0
  353. package/dist/src/safety/built-in.test.js +199 -0
  354. package/dist/src/safety/built-in.test.js.map +1 -0
  355. package/dist/src/safety/checker-runner.d.ts +48 -0
  356. package/dist/src/safety/checker-runner.js +208 -0
  357. package/dist/src/safety/checker-runner.js.map +1 -0
  358. package/dist/src/safety/checker-runner.test.d.ts +6 -0
  359. package/dist/src/safety/checker-runner.test.js +238 -0
  360. package/dist/src/safety/checker-runner.test.js.map +1 -0
  361. package/dist/src/safety/context-builder.d.ts +23 -0
  362. package/dist/src/safety/context-builder.js +47 -0
  363. package/dist/src/safety/context-builder.js.map +1 -0
  364. package/dist/src/safety/context-builder.test.d.ts +6 -0
  365. package/dist/src/safety/context-builder.test.js +49 -0
  366. package/dist/src/safety/context-builder.test.js.map +1 -0
  367. package/dist/src/safety/protocol.d.ts +88 -0
  368. package/dist/src/safety/protocol.js +15 -0
  369. package/dist/src/safety/protocol.js.map +1 -0
  370. package/dist/src/safety/registry.d.ts +26 -0
  371. package/dist/src/safety/registry.js +65 -0
  372. package/dist/src/safety/registry.js.map +1 -0
  373. package/dist/src/safety/registry.test.d.ts +6 -0
  374. package/dist/src/safety/registry.test.js +31 -0
  375. package/dist/src/safety/registry.test.js.map +1 -0
  376. package/dist/src/services/chatCompressionService.d.ts +32 -0
  377. package/dist/src/services/chatCompressionService.js +162 -0
  378. package/dist/src/services/chatCompressionService.js.map +1 -0
  379. package/dist/src/services/chatCompressionService.test.d.ts +6 -0
  380. package/dist/src/services/chatCompressionService.test.js +210 -0
  381. package/dist/src/services/chatCompressionService.test.js.map +1 -0
  382. package/dist/src/services/chatRecordingService.d.ts +3 -2
  383. package/dist/src/services/chatRecordingService.js +11 -9
  384. package/dist/src/services/chatRecordingService.js.map +1 -1
  385. package/dist/src/services/fileDiscoveryService.d.ts +2 -14
  386. package/dist/src/services/fileDiscoveryService.js +19 -55
  387. package/dist/src/services/fileDiscoveryService.js.map +1 -1
  388. package/dist/src/services/fileDiscoveryService.test.js +91 -11
  389. package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
  390. package/dist/src/services/loopDetectionService.d.ts +4 -1
  391. package/dist/src/services/loopDetectionService.js +95 -42
  392. package/dist/src/services/loopDetectionService.js.map +1 -1
  393. package/dist/src/services/loopDetectionService.test.js +220 -12
  394. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  395. package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
  396. package/dist/src/services/modelConfig.golden.test.js +42 -0
  397. package/dist/src/services/modelConfig.golden.test.js.map +1 -0
  398. package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
  399. package/dist/src/services/modelConfig.integration.test.js +247 -0
  400. package/dist/src/services/modelConfig.integration.test.js.map +1 -0
  401. package/dist/src/services/modelConfigService.d.ts +48 -0
  402. package/dist/src/services/modelConfigService.js +151 -0
  403. package/dist/src/services/modelConfigService.js.map +1 -0
  404. package/dist/src/services/modelConfigService.test.d.ts +6 -0
  405. package/dist/src/services/modelConfigService.test.js +531 -0
  406. package/dist/src/services/modelConfigService.test.js.map +1 -0
  407. package/dist/src/services/shellExecutionService.d.ts +1 -0
  408. package/dist/src/services/shellExecutionService.js +195 -92
  409. package/dist/src/services/shellExecutionService.js.map +1 -1
  410. package/dist/src/services/shellExecutionService.test.js +137 -14
  411. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  412. package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
  413. package/dist/src/telemetry/activity-monitor.d.ts +116 -0
  414. package/dist/src/telemetry/activity-monitor.js +209 -0
  415. package/dist/src/telemetry/activity-monitor.js.map +1 -0
  416. package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
  417. package/dist/src/telemetry/activity-monitor.test.js +251 -0
  418. package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
  419. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +25 -7
  420. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +294 -76
  421. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  422. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
  423. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +192 -66
  424. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  425. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +25 -3
  426. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +59 -5
  427. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  428. package/dist/src/telemetry/constants.d.ts +0 -28
  429. package/dist/src/telemetry/constants.js +0 -29
  430. package/dist/src/telemetry/constants.js.map +1 -1
  431. package/dist/src/telemetry/gcp-exporters.js +0 -1
  432. package/dist/src/telemetry/gcp-exporters.js.map +1 -1
  433. package/dist/src/telemetry/gcp-exporters.test.js +1 -1
  434. package/dist/src/telemetry/gcp-exporters.test.js.map +1 -1
  435. package/dist/src/telemetry/index.d.ts +7 -3
  436. package/dist/src/telemetry/index.js +13 -4
  437. package/dist/src/telemetry/index.js.map +1 -1
  438. package/dist/src/telemetry/loggers.d.ts +14 -7
  439. package/dist/src/telemetry/loggers.js +197 -320
  440. package/dist/src/telemetry/loggers.js.map +1 -1
  441. package/dist/src/telemetry/loggers.test.circular.js +0 -1
  442. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  443. package/dist/src/telemetry/loggers.test.js +460 -59
  444. package/dist/src/telemetry/loggers.test.js.map +1 -1
  445. package/dist/src/telemetry/memory-monitor.d.ts +149 -0
  446. package/dist/src/telemetry/memory-monitor.js +335 -0
  447. package/dist/src/telemetry/memory-monitor.js.map +1 -0
  448. package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
  449. package/dist/src/telemetry/memory-monitor.test.js +472 -0
  450. package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
  451. package/dist/src/telemetry/metrics.d.ts +180 -4
  452. package/dist/src/telemetry/metrics.js +270 -6
  453. package/dist/src/telemetry/metrics.js.map +1 -1
  454. package/dist/src/telemetry/metrics.test.js +502 -184
  455. package/dist/src/telemetry/metrics.test.js.map +1 -1
  456. package/dist/src/telemetry/sdk.js +3 -2
  457. package/dist/src/telemetry/sdk.js.map +1 -1
  458. package/dist/src/telemetry/semantic.d.ts +82 -0
  459. package/dist/src/telemetry/semantic.js +269 -0
  460. package/dist/src/telemetry/semantic.js.map +1 -0
  461. package/dist/src/telemetry/semantic.test.d.ts +6 -0
  462. package/dist/src/telemetry/semantic.test.js +387 -0
  463. package/dist/src/telemetry/semantic.test.js.map +1 -0
  464. package/dist/src/telemetry/telemetry-utils.test.js +29 -28
  465. package/dist/src/telemetry/telemetry-utils.test.js.map +1 -1
  466. package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
  467. package/dist/src/telemetry/telemetryAttributes.js +19 -0
  468. package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
  469. package/dist/src/telemetry/trace.d.ts +46 -0
  470. package/dist/src/telemetry/trace.js +121 -0
  471. package/dist/src/telemetry/trace.js.map +1 -0
  472. package/dist/src/telemetry/types.d.ts +227 -29
  473. package/dist/src/telemetry/types.js +858 -72
  474. package/dist/src/telemetry/types.js.map +1 -1
  475. package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
  476. package/dist/src/telemetry/uiTelemetry.js +7 -7
  477. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  478. package/dist/src/telemetry/uiTelemetry.test.js +89 -67
  479. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  480. package/dist/src/test-utils/config.d.ts +1 -1
  481. package/dist/src/test-utils/config.js +1 -1
  482. package/dist/src/tools/base-tool-invocation.test.d.ts +6 -0
  483. package/dist/src/tools/base-tool-invocation.test.js +85 -0
  484. package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
  485. package/dist/src/tools/edit.d.ts +4 -3
  486. package/dist/src/tools/edit.js +50 -47
  487. package/dist/src/tools/edit.js.map +1 -1
  488. package/dist/src/tools/edit.test.js +306 -216
  489. package/dist/src/tools/edit.test.js.map +1 -1
  490. package/dist/src/tools/glob.d.ts +4 -3
  491. package/dist/src/tools/glob.js +24 -27
  492. package/dist/src/tools/glob.js.map +1 -1
  493. package/dist/src/tools/glob.test.js +212 -205
  494. package/dist/src/tools/glob.test.js.map +1 -1
  495. package/dist/src/tools/grep.d.ts +4 -3
  496. package/dist/src/tools/grep.js +31 -25
  497. package/dist/src/tools/grep.js.map +1 -1
  498. package/dist/src/tools/grep.test.js +15 -12
  499. package/dist/src/tools/grep.test.js.map +1 -1
  500. package/dist/src/tools/ls.d.ts +4 -3
  501. package/dist/src/tools/ls.js +29 -35
  502. package/dist/src/tools/ls.js.map +1 -1
  503. package/dist/src/tools/ls.test.js +34 -42
  504. package/dist/src/tools/ls.test.js.map +1 -1
  505. package/dist/src/tools/mcp-client-manager.d.ts +49 -11
  506. package/dist/src/tools/mcp-client-manager.js +191 -31
  507. package/dist/src/tools/mcp-client-manager.js.map +1 -1
  508. package/dist/src/tools/mcp-client-manager.test.js +132 -25
  509. package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
  510. package/dist/src/tools/mcp-client.d.ts +12 -5
  511. package/dist/src/tools/mcp-client.js +287 -267
  512. package/dist/src/tools/mcp-client.js.map +1 -1
  513. package/dist/src/tools/mcp-client.test.js +352 -45
  514. package/dist/src/tools/mcp-client.test.js.map +1 -1
  515. package/dist/src/tools/mcp-tool.d.ts +6 -2
  516. package/dist/src/tools/mcp-tool.js +19 -8
  517. package/dist/src/tools/mcp-tool.js.map +1 -1
  518. package/dist/src/tools/mcp-tool.test.js +186 -273
  519. package/dist/src/tools/mcp-tool.test.js.map +1 -1
  520. package/dist/src/tools/memoryTool.d.ts +7 -5
  521. package/dist/src/tools/memoryTool.js +14 -12
  522. package/dist/src/tools/memoryTool.js.map +1 -1
  523. package/dist/src/tools/memoryTool.test.js +10 -9
  524. package/dist/src/tools/memoryTool.test.js.map +1 -1
  525. package/dist/src/tools/message-bus-integration.test.js +14 -1
  526. package/dist/src/tools/message-bus-integration.test.js.map +1 -1
  527. package/dist/src/tools/modifiable-tool.d.ts +5 -1
  528. package/dist/src/tools/modifiable-tool.js +38 -16
  529. package/dist/src/tools/modifiable-tool.js.map +1 -1
  530. package/dist/src/tools/modifiable-tool.test.js +66 -31
  531. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  532. package/dist/src/tools/read-file.d.ts +6 -5
  533. package/dist/src/tools/read-file.js +26 -32
  534. package/dist/src/tools/read-file.js.map +1 -1
  535. package/dist/src/tools/read-file.test.js +68 -33
  536. package/dist/src/tools/read-file.test.js.map +1 -1
  537. package/dist/src/tools/read-many-files.d.ts +6 -12
  538. package/dist/src/tools/read-many-files.js +28 -57
  539. package/dist/src/tools/read-many-files.js.map +1 -1
  540. package/dist/src/tools/read-many-files.test.js +37 -36
  541. package/dist/src/tools/read-many-files.test.js.map +1 -1
  542. package/dist/src/tools/ripGrep.d.ts +28 -10
  543. package/dist/src/tools/ripGrep.js +195 -193
  544. package/dist/src/tools/ripGrep.js.map +1 -1
  545. package/dist/src/tools/ripGrep.test.js +533 -204
  546. package/dist/src/tools/ripGrep.test.js.map +1 -1
  547. package/dist/src/tools/shell.d.ts +8 -6
  548. package/dist/src/tools/shell.js +64 -38
  549. package/dist/src/tools/shell.js.map +1 -1
  550. package/dist/src/tools/shell.test.js +134 -43
  551. package/dist/src/tools/shell.test.js.map +1 -1
  552. package/dist/src/tools/smart-edit.d.ts +10 -23
  553. package/dist/src/tools/smart-edit.js +100 -85
  554. package/dist/src/tools/smart-edit.js.map +1 -1
  555. package/dist/src/tools/smart-edit.test.js +229 -179
  556. package/dist/src/tools/smart-edit.test.js.map +1 -1
  557. package/dist/src/tools/tool-error.d.ts +21 -0
  558. package/dist/src/tools/tool-error.js +27 -0
  559. package/dist/src/tools/tool-error.js.map +1 -1
  560. package/dist/src/tools/tool-names.d.ts +17 -0
  561. package/dist/src/tools/tool-names.js +21 -0
  562. package/dist/src/tools/tool-names.js.map +1 -0
  563. package/dist/src/tools/tool-registry.d.ts +32 -20
  564. package/dist/src/tools/tool-registry.js +122 -78
  565. package/dist/src/tools/tool-registry.js.map +1 -1
  566. package/dist/src/tools/tool-registry.test.js +167 -90
  567. package/dist/src/tools/tool-registry.test.js.map +1 -1
  568. package/dist/src/tools/tools.d.ts +23 -8
  569. package/dist/src/tools/tools.js +69 -37
  570. package/dist/src/tools/tools.js.map +1 -1
  571. package/dist/src/tools/web-fetch.d.ts +11 -3
  572. package/dist/src/tools/web-fetch.js +80 -38
  573. package/dist/src/tools/web-fetch.js.map +1 -1
  574. package/dist/src/tools/web-fetch.test.js +338 -9
  575. package/dist/src/tools/web-fetch.test.js.map +1 -1
  576. package/dist/src/tools/web-search.d.ts +4 -3
  577. package/dist/src/tools/web-search.js +11 -9
  578. package/dist/src/tools/web-search.js.map +1 -1
  579. package/dist/src/tools/web-search.test.js +6 -0
  580. package/dist/src/tools/web-search.test.js.map +1 -1
  581. package/dist/src/tools/write-file.d.ts +3 -2
  582. package/dist/src/tools/write-file.js +41 -40
  583. package/dist/src/tools/write-file.js.map +1 -1
  584. package/dist/src/tools/write-file.test.js +130 -123
  585. package/dist/src/tools/write-file.test.js.map +1 -1
  586. package/dist/src/tools/write-todos.d.ts +34 -9
  587. package/dist/src/tools/write-todos.js +54 -11
  588. package/dist/src/tools/write-todos.js.map +1 -1
  589. package/dist/src/tools/write-todos.test.js +2 -2
  590. package/dist/src/tools/write-todos.test.js.map +1 -1
  591. package/dist/src/utils/bfsFileSearch.js +3 -2
  592. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  593. package/dist/src/utils/channel.d.ts +19 -0
  594. package/dist/src/utils/channel.js +49 -0
  595. package/dist/src/utils/channel.js.map +1 -0
  596. package/dist/src/utils/channel.test.d.ts +6 -0
  597. package/dist/src/utils/channel.test.js +170 -0
  598. package/dist/src/utils/channel.test.js.map +1 -0
  599. package/dist/src/utils/debugLogger.d.ts +25 -0
  600. package/dist/src/utils/debugLogger.js +33 -0
  601. package/dist/src/utils/debugLogger.js.map +1 -0
  602. package/dist/src/utils/debugLogger.test.d.ts +6 -0
  603. package/dist/src/utils/debugLogger.test.js +69 -0
  604. package/dist/src/utils/debugLogger.test.js.map +1 -0
  605. package/dist/src/utils/delay.d.ts +16 -0
  606. package/dist/src/utils/delay.js +43 -0
  607. package/dist/src/utils/delay.js.map +1 -0
  608. package/dist/src/utils/delay.test.d.ts +6 -0
  609. package/dist/src/utils/delay.test.js +88 -0
  610. package/dist/src/utils/delay.test.js.map +1 -0
  611. package/dist/src/utils/editCorrector.js +10 -25
  612. package/dist/src/utils/editCorrector.js.map +1 -1
  613. package/dist/src/utils/editCorrector.test.js +19 -5
  614. package/dist/src/utils/editCorrector.test.js.map +1 -1
  615. package/dist/src/utils/editor.d.ts +4 -2
  616. package/dist/src/utils/editor.js +53 -39
  617. package/dist/src/utils/editor.js.map +1 -1
  618. package/dist/src/utils/editor.test.js +18 -45
  619. package/dist/src/utils/editor.test.js.map +1 -1
  620. package/dist/src/utils/environmentContext.d.ts +2 -1
  621. package/dist/src/utils/environmentContext.js +20 -33
  622. package/dist/src/utils/environmentContext.js.map +1 -1
  623. package/dist/src/utils/environmentContext.test.js +6 -34
  624. package/dist/src/utils/environmentContext.test.js.map +1 -1
  625. package/dist/src/utils/errorParsing.d.ts +1 -1
  626. package/dist/src/utils/errorParsing.js +5 -33
  627. package/dist/src/utils/errorParsing.js.map +1 -1
  628. package/dist/src/utils/errorParsing.test.js +0 -88
  629. package/dist/src/utils/errorParsing.test.js.map +1 -1
  630. package/dist/src/utils/errors.d.ts +3 -0
  631. package/dist/src/utils/errors.js +6 -0
  632. package/dist/src/utils/errors.js.map +1 -1
  633. package/dist/src/utils/events.d.ts +121 -0
  634. package/dist/src/utils/events.js +84 -0
  635. package/dist/src/utils/events.js.map +1 -0
  636. package/dist/src/utils/events.test.d.ts +6 -0
  637. package/dist/src/utils/events.test.js +212 -0
  638. package/dist/src/utils/events.test.js.map +1 -0
  639. package/dist/src/utils/extensionLoader.d.ts +86 -0
  640. package/dist/src/utils/extensionLoader.js +208 -0
  641. package/dist/src/utils/extensionLoader.js.map +1 -0
  642. package/dist/src/utils/extensionLoader.test.d.ts +6 -0
  643. package/dist/src/utils/extensionLoader.test.js +154 -0
  644. package/dist/src/utils/extensionLoader.test.js.map +1 -0
  645. package/dist/src/utils/fetch.d.ts +1 -0
  646. package/dist/src/utils/fetch.js +4 -0
  647. package/dist/src/utils/fetch.js.map +1 -1
  648. package/dist/src/utils/fileUtils.d.ts +4 -0
  649. package/dist/src/utils/fileUtils.js +34 -2
  650. package/dist/src/utils/fileUtils.js.map +1 -1
  651. package/dist/src/utils/fileUtils.test.js +87 -61
  652. package/dist/src/utils/fileUtils.test.js.map +1 -1
  653. package/dist/src/utils/filesearch/fileSearch.js +1 -1
  654. package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
  655. package/dist/src/utils/flashFallback.test.js +28 -47
  656. package/dist/src/utils/flashFallback.test.js.map +1 -1
  657. package/dist/src/utils/formatters.d.ts +1 -0
  658. package/dist/src/utils/formatters.js +2 -1
  659. package/dist/src/utils/formatters.js.map +1 -1
  660. package/dist/src/utils/formatters.test.d.ts +6 -0
  661. package/dist/src/utils/formatters.test.js +26 -0
  662. package/dist/src/utils/formatters.test.js.map +1 -0
  663. package/dist/src/utils/getFolderStructure.js +9 -17
  664. package/dist/src/utils/getFolderStructure.js.map +1 -1
  665. package/dist/src/utils/getFolderStructure.test.js +7 -6
  666. package/dist/src/utils/getFolderStructure.test.js.map +1 -1
  667. package/dist/src/utils/gitIgnoreParser.d.ts +4 -1
  668. package/dist/src/utils/gitIgnoreParser.js +28 -10
  669. package/dist/src/utils/gitIgnoreParser.js.map +1 -1
  670. package/dist/src/utils/gitIgnoreParser.test.js +58 -0
  671. package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
  672. package/dist/src/utils/googleErrors.d.ts +104 -0
  673. package/dist/src/utils/googleErrors.js +152 -0
  674. package/dist/src/utils/googleErrors.js.map +1 -0
  675. package/dist/src/utils/googleErrors.test.d.ts +6 -0
  676. package/dist/src/utils/googleErrors.test.js +301 -0
  677. package/dist/src/utils/googleErrors.test.js.map +1 -0
  678. package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
  679. package/dist/src/utils/googleQuotaErrors.js +157 -0
  680. package/dist/src/utils/googleQuotaErrors.js.map +1 -0
  681. package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
  682. package/dist/src/utils/googleQuotaErrors.test.js +311 -0
  683. package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
  684. package/dist/src/utils/httpErrors.d.ts +18 -0
  685. package/dist/src/utils/httpErrors.js +36 -0
  686. package/dist/src/utils/httpErrors.js.map +1 -0
  687. package/dist/src/utils/ignorePatterns.test.js +26 -30
  688. package/dist/src/utils/ignorePatterns.test.js.map +1 -1
  689. package/dist/src/utils/installationManager.js +2 -1
  690. package/dist/src/utils/installationManager.js.map +1 -1
  691. package/dist/src/utils/installationManager.test.js +6 -4
  692. package/dist/src/utils/installationManager.test.js.map +1 -1
  693. package/dist/src/utils/llm-edit-fixer.d.ts +1 -1
  694. package/dist/src/utils/llm-edit-fixer.js +33 -9
  695. package/dist/src/utils/llm-edit-fixer.js.map +1 -1
  696. package/dist/src/utils/llm-edit-fixer.test.js +38 -1
  697. package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
  698. package/dist/src/utils/memoryDiscovery.d.ts +20 -1
  699. package/dist/src/utils/memoryDiscovery.js +176 -12
  700. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  701. package/dist/src/utils/memoryDiscovery.test.js +299 -40
  702. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  703. package/dist/src/utils/memoryImportProcessor.js +4 -3
  704. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  705. package/dist/src/utils/memoryImportProcessor.test.js +8 -14
  706. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  707. package/dist/src/utils/nextSpeakerChecker.js +3 -3
  708. package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
  709. package/dist/src/utils/nextSpeakerChecker.test.js +13 -5
  710. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  711. package/dist/src/utils/package.d.ts +12 -0
  712. package/dist/src/utils/package.js +15 -0
  713. package/dist/src/utils/package.js.map +1 -0
  714. package/dist/src/utils/pathCorrector.d.ts +25 -0
  715. package/dist/src/utils/pathCorrector.js +33 -0
  716. package/dist/src/utils/pathCorrector.js.map +1 -0
  717. package/dist/src/utils/pathCorrector.test.d.ts +6 -0
  718. package/dist/src/utils/pathCorrector.test.js +83 -0
  719. package/dist/src/utils/pathCorrector.test.js.map +1 -0
  720. package/dist/src/utils/pathReader.js +4 -4
  721. package/dist/src/utils/pathReader.js.map +1 -1
  722. package/dist/src/utils/pathReader.test.js +44 -1
  723. package/dist/src/utils/pathReader.test.js.map +1 -1
  724. package/dist/src/utils/paths.d.ts +1 -1
  725. package/dist/src/utils/paths.js +131 -29
  726. package/dist/src/utils/paths.js.map +1 -1
  727. package/dist/src/utils/paths.test.js +200 -68
  728. package/dist/src/utils/paths.test.js.map +1 -1
  729. package/dist/src/utils/quotaErrorDetection.d.ts +0 -2
  730. package/dist/src/utils/quotaErrorDetection.js +0 -46
  731. package/dist/src/utils/quotaErrorDetection.js.map +1 -1
  732. package/dist/src/utils/retry.d.ts +3 -10
  733. package/dist/src/utils/retry.js +97 -195
  734. package/dist/src/utils/retry.js.map +1 -1
  735. package/dist/src/utils/retry.test.js +179 -145
  736. package/dist/src/utils/retry.test.js.map +1 -1
  737. package/dist/src/utils/safeJsonStringify.d.ts +4 -4
  738. package/dist/src/utils/safeJsonStringify.js +31 -7
  739. package/dist/src/utils/safeJsonStringify.js.map +1 -1
  740. package/dist/src/utils/shell-utils.d.ts +15 -2
  741. package/dist/src/utils/shell-utils.js +387 -140
  742. package/dist/src/utils/shell-utils.js.map +1 -1
  743. package/dist/src/utils/shell-utils.test.js +244 -62
  744. package/dist/src/utils/shell-utils.test.js.map +1 -1
  745. package/dist/src/utils/stdio.d.ts +32 -0
  746. package/dist/src/utils/stdio.js +85 -0
  747. package/dist/src/utils/stdio.js.map +1 -0
  748. package/dist/src/utils/stdio.test.d.ts +6 -0
  749. package/dist/src/utils/stdio.test.js +47 -0
  750. package/dist/src/utils/stdio.test.js.map +1 -0
  751. package/dist/src/utils/summarizer.d.ts +4 -2
  752. package/dist/src/utils/summarizer.js +8 -9
  753. package/dist/src/utils/summarizer.js.map +1 -1
  754. package/dist/src/utils/summarizer.test.js +32 -12
  755. package/dist/src/utils/summarizer.test.js.map +1 -1
  756. package/dist/src/utils/systemEncoding.js +5 -4
  757. package/dist/src/utils/systemEncoding.js.map +1 -1
  758. package/dist/src/utils/systemEncoding.test.js +2 -1
  759. package/dist/src/utils/systemEncoding.test.js.map +1 -1
  760. package/dist/src/utils/terminal.d.ts +14 -0
  761. package/dist/src/utils/terminal.js +38 -0
  762. package/dist/src/utils/terminal.js.map +1 -0
  763. package/dist/src/utils/tool-utils.d.ts +2 -2
  764. package/dist/src/utils/tool-utils.js +15 -6
  765. package/dist/src/utils/tool-utils.js.map +1 -1
  766. package/dist/src/utils/tool-utils.test.js +8 -0
  767. package/dist/src/utils/tool-utils.test.js.map +1 -1
  768. package/dist/src/utils/userAccountManager.js +5 -4
  769. package/dist/src/utils/userAccountManager.js.map +1 -1
  770. package/dist/src/utils/userAccountManager.test.js +9 -7
  771. package/dist/src/utils/userAccountManager.test.js.map +1 -1
  772. package/dist/src/utils/workspaceContext.d.ts +4 -3
  773. package/dist/src/utils/workspaceContext.js +13 -13
  774. package/dist/src/utils/workspaceContext.js.map +1 -1
  775. package/dist/src/utils/workspaceContext.test.js +8 -7
  776. package/dist/src/utils/workspaceContext.test.js.map +1 -1
  777. package/dist/tsconfig.tsbuildinfo +1 -1
  778. package/package.json +12 -7
@@ -3,15 +3,18 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { ToolConfirmationOutcome, ApprovalMode, logToolCall, ReadFileTool, ToolErrorType, ToolCallEvent, ShellTool, logToolOutputTruncated, ToolOutputTruncatedEvent, } from '../index.js';
6
+ import { ToolConfirmationOutcome, ApprovalMode, logToolCall, ToolErrorType, ToolCallEvent, logToolOutputTruncated, ToolOutputTruncatedEvent, runInDevTraceSpan, } from '../index.js';
7
+ import { READ_FILE_TOOL_NAME, SHELL_TOOL_NAME } from '../tools/tool-names.js';
7
8
  import { getResponseTextFromParts } from '../utils/generateContentResponseUtilities.js';
8
9
  import { isModifiableDeclarativeTool, modifyWithEditor, } from '../tools/modifiable-tool.js';
9
10
  import * as Diff from 'diff';
10
11
  import * as fs from 'node:fs/promises';
11
12
  import * as path from 'node:path';
13
+ import { isShellInvocationAllowlisted, SHELL_TOOL_NAMES, } from '../utils/shell-utils.js';
12
14
  import { doesToolInvocationMatch } from '../utils/tool-utils.js';
13
15
  import levenshtein from 'fast-levenshtein';
14
16
  import { ShellToolInvocation } from '../tools/shell.js';
17
+ import { MessageBusType } from '../confirmation-bus/types.js';
15
18
  /**
16
19
  * Formats tool output for a Gemini FunctionResponse.
17
20
  */
@@ -124,10 +127,10 @@ export async function truncateAndSaveToFile(content, callId, projectTempDir, thr
124
127
  return {
125
128
  content: `Tool output was too large and has been truncated.
126
129
  The full output has been saved to: ${outputFile}
127
- To read the complete output, use the ${ReadFileTool.Name} tool with the absolute file path above. For large files, you can use the offset and limit parameters to read specific sections:
128
- - ${ReadFileTool.Name} tool with offset=0, limit=100 to see the first 100 lines
129
- - ${ReadFileTool.Name} tool with offset=N to skip N lines from the beginning
130
- - ${ReadFileTool.Name} tool with limit=M to read only M lines at a time
130
+ To read the complete output, use the ${READ_FILE_TOOL_NAME} tool with the absolute file path above. For large files, you can use the offset and limit parameters to read specific sections:
131
+ - ${READ_FILE_TOOL_NAME} tool with offset=0, limit=100 to see the first 100 lines
132
+ - ${READ_FILE_TOOL_NAME} tool with offset=N to skip N lines from the beginning
133
+ - ${READ_FILE_TOOL_NAME} tool with limit=M to read only M lines at a time
131
134
  The truncated output below shows the beginning and end of the content. The marker '... [CONTENT TRUNCATED] ...' indicates where content was removed.
132
135
  This allows you to efficiently examine different parts of the output without loading the entire file.
133
136
  Truncated part of the output:
@@ -142,27 +145,53 @@ ${truncatedContent}`,
142
145
  }
143
146
  }
144
147
  export class CoreToolScheduler {
145
- toolRegistry;
148
+ // Static WeakMap to track which MessageBus instances already have a handler subscribed
149
+ // This prevents duplicate subscriptions when multiple CoreToolScheduler instances are created
150
+ static subscribedMessageBuses = new WeakMap();
146
151
  toolCalls = [];
147
152
  outputUpdateHandler;
148
153
  onAllToolCallsComplete;
149
154
  onToolCallsUpdate;
150
155
  getPreferredEditor;
151
156
  config;
152
- onEditorClose;
153
157
  isFinalizingToolCalls = false;
154
158
  isScheduling = false;
159
+ isCancelling = false;
155
160
  requestQueue = [];
161
+ toolCallQueue = [];
162
+ completedToolCallsForBatch = [];
156
163
  constructor(options) {
157
164
  this.config = options.config;
158
- this.toolRegistry = options.config.getToolRegistry();
159
165
  this.outputUpdateHandler = options.outputUpdateHandler;
160
166
  this.onAllToolCallsComplete = options.onAllToolCallsComplete;
161
167
  this.onToolCallsUpdate = options.onToolCallsUpdate;
162
168
  this.getPreferredEditor = options.getPreferredEditor;
163
- this.onEditorClose = options.onEditorClose;
169
+ // Subscribe to message bus for ASK_USER policy decisions
170
+ // Use a static WeakMap to ensure we only subscribe ONCE per MessageBus instance
171
+ // This prevents memory leaks when multiple CoreToolScheduler instances are created
172
+ // (e.g., on every React render, or for each non-interactive tool call)
173
+ if (this.config.getEnableMessageBusIntegration()) {
174
+ const messageBus = this.config.getMessageBus();
175
+ // Check if we've already subscribed a handler to this message bus
176
+ if (!CoreToolScheduler.subscribedMessageBuses.has(messageBus)) {
177
+ // Create a shared handler that will be used for this message bus
178
+ const sharedHandler = (request) => {
179
+ // When ASK_USER policy decision is made, respond with requiresUserConfirmation=true
180
+ // to tell tools to use their legacy confirmation flow
181
+ messageBus.publish({
182
+ type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
183
+ correlationId: request.correlationId,
184
+ confirmed: false,
185
+ requiresUserConfirmation: true,
186
+ });
187
+ };
188
+ messageBus.subscribe(MessageBusType.TOOL_CONFIRMATION_REQUEST, sharedHandler);
189
+ // Store the handler in the WeakMap so we don't subscribe again
190
+ CoreToolScheduler.subscribedMessageBuses.set(messageBus, sharedHandler);
191
+ }
192
+ }
164
193
  }
165
- setStatusInternal(targetCallId, newStatus, auxiliaryData) {
194
+ setStatusInternal(targetCallId, newStatus, signal, auxiliaryData) {
166
195
  this.toolCalls = this.toolCalls.map((currentCall) => {
167
196
  if (currentCall.request.callId !== targetCallId ||
168
197
  currentCall.status === 'success' ||
@@ -292,7 +321,6 @@ export class CoreToolScheduler {
292
321
  }
293
322
  });
294
323
  this.notifyToolCallsUpdate();
295
- this.checkAndNotifyCompletion();
296
324
  }
297
325
  setArgsInternal(targetCallId, args) {
298
326
  this.toolCalls = this.toolCalls.map((call) => {
@@ -341,7 +369,7 @@ export class CoreToolScheduler {
341
369
  * @returns A suggestion string like " Did you mean 'tool'?" or " Did you mean one of: 'tool1', 'tool2'?", or an empty string if no suggestions are found.
342
370
  */
343
371
  getToolSuggestion(unknownToolName, topN = 3) {
344
- const allToolNames = this.toolRegistry.getAllToolNames();
372
+ const allToolNames = this.config.getToolRegistry().getAllToolNames();
345
373
  const matches = allToolNames.map((toolName) => ({
346
374
  name: toolName,
347
375
  distance: levenshtein.get(unknownToolName, toolName),
@@ -362,42 +390,70 @@ export class CoreToolScheduler {
362
390
  }
363
391
  }
364
392
  schedule(request, signal) {
365
- if (this.isRunning() || this.isScheduling) {
366
- return new Promise((resolve, reject) => {
367
- const abortHandler = () => {
368
- // Find and remove the request from the queue
369
- const index = this.requestQueue.findIndex((item) => item.request === request);
370
- if (index > -1) {
371
- this.requestQueue.splice(index, 1);
372
- reject(new Error('Tool call cancelled while in queue.'));
373
- }
374
- };
375
- signal.addEventListener('abort', abortHandler, { once: true });
376
- this.requestQueue.push({
377
- request,
378
- signal,
379
- resolve: () => {
380
- signal.removeEventListener('abort', abortHandler);
381
- resolve();
382
- },
383
- reject: (reason) => {
384
- signal.removeEventListener('abort', abortHandler);
385
- reject(reason);
386
- },
393
+ return runInDevTraceSpan({ name: 'schedule' }, async ({ metadata: spanMetadata }) => {
394
+ spanMetadata.input = request;
395
+ if (this.isRunning() || this.isScheduling) {
396
+ return new Promise((resolve, reject) => {
397
+ const abortHandler = () => {
398
+ // Find and remove the request from the queue
399
+ const index = this.requestQueue.findIndex((item) => item.request === request);
400
+ if (index > -1) {
401
+ this.requestQueue.splice(index, 1);
402
+ reject(new Error('Tool call cancelled while in queue.'));
403
+ }
404
+ };
405
+ signal.addEventListener('abort', abortHandler, { once: true });
406
+ this.requestQueue.push({
407
+ request,
408
+ signal,
409
+ resolve: () => {
410
+ signal.removeEventListener('abort', abortHandler);
411
+ resolve();
412
+ },
413
+ reject: (reason) => {
414
+ signal.removeEventListener('abort', abortHandler);
415
+ reject(reason);
416
+ },
417
+ });
387
418
  });
388
- });
419
+ }
420
+ return this._schedule(request, signal);
421
+ });
422
+ }
423
+ cancelAll(signal) {
424
+ if (this.isCancelling) {
425
+ return;
426
+ }
427
+ this.isCancelling = true;
428
+ // Cancel the currently active tool call, if there is one.
429
+ if (this.toolCalls.length > 0) {
430
+ const activeCall = this.toolCalls[0];
431
+ // Only cancel if it's in a cancellable state.
432
+ if (activeCall.status === 'awaiting_approval' ||
433
+ activeCall.status === 'executing' ||
434
+ activeCall.status === 'scheduled' ||
435
+ activeCall.status === 'validating') {
436
+ this.setStatusInternal(activeCall.request.callId, 'cancelled', signal, 'User cancelled the operation.');
437
+ }
389
438
  }
390
- return this._schedule(request, signal);
439
+ // Clear the queue and mark all queued items as cancelled for completion reporting.
440
+ this._cancelAllQueuedCalls();
441
+ // Finalize the batch immediately.
442
+ void this.checkAndNotifyCompletion(signal);
391
443
  }
392
444
  async _schedule(request, signal) {
393
445
  this.isScheduling = true;
446
+ this.isCancelling = false;
394
447
  try {
395
448
  if (this.isRunning()) {
396
449
  throw new Error('Cannot schedule new tool calls while other tool calls are actively running (executing or awaiting approval).');
397
450
  }
398
451
  const requestsToProcess = Array.isArray(request) ? request : [request];
452
+ this.completedToolCallsForBatch = [];
399
453
  const newToolCalls = requestsToProcess.map((reqInfo) => {
400
- const toolInstance = this.toolRegistry.getTool(reqInfo.name);
454
+ const toolInstance = this.config
455
+ .getToolRegistry()
456
+ .getTool(reqInfo.name);
401
457
  if (!toolInstance) {
402
458
  const suggestion = this.getToolSuggestion(reqInfo.name);
403
459
  const errorMessage = `Tool "${reqInfo.name}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
@@ -426,29 +482,55 @@ export class CoreToolScheduler {
426
482
  startTime: Date.now(),
427
483
  };
428
484
  });
429
- this.toolCalls = this.toolCalls.concat(newToolCalls);
430
- this.notifyToolCallsUpdate();
431
- for (const toolCall of newToolCalls) {
432
- if (toolCall.status !== 'validating') {
433
- continue;
485
+ this.toolCallQueue.push(...newToolCalls);
486
+ await this._processNextInQueue(signal);
487
+ }
488
+ finally {
489
+ this.isScheduling = false;
490
+ }
491
+ }
492
+ async _processNextInQueue(signal) {
493
+ // If there's already a tool being processed, or the queue is empty, stop.
494
+ if (this.toolCalls.length > 0 || this.toolCallQueue.length === 0) {
495
+ return;
496
+ }
497
+ // If cancellation happened between steps, handle it.
498
+ if (signal.aborted) {
499
+ this._cancelAllQueuedCalls();
500
+ // Finalize the batch.
501
+ await this.checkAndNotifyCompletion(signal);
502
+ return;
503
+ }
504
+ const toolCall = this.toolCallQueue.shift();
505
+ // This is now the single active tool call.
506
+ this.toolCalls = [toolCall];
507
+ this.notifyToolCallsUpdate();
508
+ // Handle tools that were already errored during creation.
509
+ if (toolCall.status === 'error') {
510
+ // An error during validation means this "active" tool is already complete.
511
+ // We need to check for batch completion to either finish or process the next in queue.
512
+ await this.checkAndNotifyCompletion(signal);
513
+ return;
514
+ }
515
+ // This logic is moved from the old `for` loop in `_schedule`.
516
+ if (toolCall.status === 'validating') {
517
+ const { request: reqInfo, invocation } = toolCall;
518
+ try {
519
+ if (signal.aborted) {
520
+ this.setStatusInternal(reqInfo.callId, 'cancelled', signal, 'Tool call cancelled by user.');
521
+ // The completion check will handle the cascade.
522
+ await this.checkAndNotifyCompletion(signal);
523
+ return;
434
524
  }
435
- const { request: reqInfo, invocation } = toolCall;
436
- try {
437
- if (signal.aborted) {
438
- this.setStatusInternal(reqInfo.callId, 'cancelled', 'Tool call cancelled by user.');
439
- continue;
440
- }
441
- const confirmationDetails = await invocation.shouldConfirmExecute(signal);
442
- if (!confirmationDetails) {
443
- this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
444
- this.setStatusInternal(reqInfo.callId, 'scheduled');
445
- continue;
446
- }
447
- const allowedTools = this.config.getAllowedTools() || [];
448
- if (this.config.getApprovalMode() === ApprovalMode.YOLO ||
449
- doesToolInvocationMatch(toolCall.tool, invocation, allowedTools)) {
525
+ const confirmationDetails = await invocation.shouldConfirmExecute(signal);
526
+ if (!confirmationDetails) {
527
+ this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
528
+ this.setStatusInternal(reqInfo.callId, 'scheduled', signal);
529
+ }
530
+ else {
531
+ if (this.isAutoApproved(toolCall)) {
450
532
  this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
451
- this.setStatusInternal(reqInfo.callId, 'scheduled');
533
+ this.setStatusInternal(reqInfo.callId, 'scheduled', signal);
452
534
  }
453
535
  else {
454
536
  // Allow IDE to resolve confirmation
@@ -468,35 +550,33 @@ export class CoreToolScheduler {
468
550
  ...confirmationDetails,
469
551
  onConfirm: (outcome, payload) => this.handleConfirmationResponse(reqInfo.callId, originalOnConfirm, outcome, signal, payload),
470
552
  };
471
- this.setStatusInternal(reqInfo.callId, 'awaiting_approval', wrappedConfirmationDetails);
553
+ this.setStatusInternal(reqInfo.callId, 'awaiting_approval', signal, wrappedConfirmationDetails);
472
554
  }
473
555
  }
474
- catch (error) {
475
- if (signal.aborted) {
476
- this.setStatusInternal(reqInfo.callId, 'cancelled', 'Tool call cancelled by user.');
477
- continue;
478
- }
479
- this.setStatusInternal(reqInfo.callId, 'error', createErrorResponse(reqInfo, error instanceof Error ? error : new Error(String(error)), ToolErrorType.UNHANDLED_EXCEPTION));
556
+ }
557
+ catch (error) {
558
+ if (signal.aborted) {
559
+ this.setStatusInternal(reqInfo.callId, 'cancelled', signal, 'Tool call cancelled by user.');
560
+ await this.checkAndNotifyCompletion(signal);
561
+ }
562
+ else {
563
+ this.setStatusInternal(reqInfo.callId, 'error', signal, createErrorResponse(reqInfo, error instanceof Error ? error : new Error(String(error)), ToolErrorType.UNHANDLED_EXCEPTION));
564
+ await this.checkAndNotifyCompletion(signal);
480
565
  }
481
566
  }
482
- this.attemptExecutionOfScheduledCalls(signal);
483
- void this.checkAndNotifyCompletion();
484
- }
485
- finally {
486
- this.isScheduling = false;
487
567
  }
568
+ await this.attemptExecutionOfScheduledCalls(signal);
488
569
  }
489
570
  async handleConfirmationResponse(callId, originalOnConfirm, outcome, signal, payload) {
490
571
  const toolCall = this.toolCalls.find((c) => c.request.callId === callId && c.status === 'awaiting_approval');
491
572
  if (toolCall && toolCall.status === 'awaiting_approval') {
492
573
  await originalOnConfirm(outcome);
493
574
  }
494
- if (outcome === ToolConfirmationOutcome.ProceedAlways) {
495
- await this.autoApproveCompatiblePendingTools(signal, callId);
496
- }
497
575
  this.setToolCallOutcome(callId, outcome);
498
576
  if (outcome === ToolConfirmationOutcome.Cancel || signal.aborted) {
499
- this.setStatusInternal(callId, 'cancelled', 'User did not allow tool call');
577
+ // Instead of just cancelling one tool, trigger the full cancel cascade.
578
+ this.cancelAll(signal);
579
+ return; // `cancelAll` calls `checkAndNotifyCompletion`, so we can exit here.
500
580
  }
501
581
  else if (outcome === ToolConfirmationOutcome.ModifyWithEditor) {
502
582
  const waitingToolCall = toolCall;
@@ -506,13 +586,19 @@ export class CoreToolScheduler {
506
586
  if (!editorType) {
507
587
  return;
508
588
  }
509
- this.setStatusInternal(callId, 'awaiting_approval', {
589
+ this.setStatusInternal(callId, 'awaiting_approval', signal, {
510
590
  ...waitingToolCall.confirmationDetails,
511
591
  isModifying: true,
512
592
  });
513
- const { updatedParams, updatedDiff } = await modifyWithEditor(waitingToolCall.request.args, modifyContext, editorType, signal, this.onEditorClose);
593
+ const contentOverrides = waitingToolCall.confirmationDetails.type === 'edit'
594
+ ? {
595
+ currentContent: waitingToolCall.confirmationDetails.originalContent,
596
+ proposedContent: waitingToolCall.confirmationDetails.newContent,
597
+ }
598
+ : undefined;
599
+ const { updatedParams, updatedDiff } = await modifyWithEditor(waitingToolCall.request.args, modifyContext, editorType, signal, contentOverrides);
514
600
  this.setArgsInternal(callId, updatedParams);
515
- this.setStatusInternal(callId, 'awaiting_approval', {
601
+ this.setStatusInternal(callId, 'awaiting_approval', signal, {
516
602
  ...waitingToolCall.confirmationDetails,
517
603
  fileDiff: updatedDiff,
518
604
  isModifying: false,
@@ -524,9 +610,9 @@ export class CoreToolScheduler {
524
610
  if (payload?.newContent && toolCall) {
525
611
  await this._applyInlineModify(toolCall, payload, signal);
526
612
  }
527
- this.setStatusInternal(callId, 'scheduled');
613
+ this.setStatusInternal(callId, 'scheduled', signal);
528
614
  }
529
- this.attemptExecutionOfScheduledCalls(signal);
615
+ await this.attemptExecutionOfScheduledCalls(signal);
530
616
  }
531
617
  /**
532
618
  * Applies user-provided content changes to a tool call that is awaiting confirmation.
@@ -544,25 +630,25 @@ export class CoreToolScheduler {
544
630
  const updatedParams = modifyContext.createUpdatedParams(currentContent, payload.newContent, toolCall.request.args);
545
631
  const updatedDiff = Diff.createPatch(modifyContext.getFilePath(toolCall.request.args), currentContent, payload.newContent, 'Current', 'Proposed');
546
632
  this.setArgsInternal(toolCall.request.callId, updatedParams);
547
- this.setStatusInternal(toolCall.request.callId, 'awaiting_approval', {
633
+ this.setStatusInternal(toolCall.request.callId, 'awaiting_approval', signal, {
548
634
  ...toolCall.confirmationDetails,
549
635
  fileDiff: updatedDiff,
550
636
  });
551
637
  }
552
- attemptExecutionOfScheduledCalls(signal) {
638
+ async attemptExecutionOfScheduledCalls(signal) {
553
639
  const allCallsFinalOrScheduled = this.toolCalls.every((call) => call.status === 'scheduled' ||
554
640
  call.status === 'cancelled' ||
555
641
  call.status === 'success' ||
556
642
  call.status === 'error');
557
643
  if (allCallsFinalOrScheduled) {
558
644
  const callsToExecute = this.toolCalls.filter((call) => call.status === 'scheduled');
559
- callsToExecute.forEach((toolCall) => {
645
+ for (const toolCall of callsToExecute) {
560
646
  if (toolCall.status !== 'scheduled')
561
- return;
647
+ continue;
562
648
  const scheduledCall = toolCall;
563
649
  const { callId, name: toolName } = scheduledCall.request;
564
650
  const invocation = scheduledCall.invocation;
565
- this.setStatusInternal(callId, 'executing');
651
+ this.setStatusInternal(callId, 'executing', signal);
566
652
  const liveOutputCallback = scheduledCall.tool.canUpdateOutput && this.outputUpdateHandler
567
653
  ? (outputChunk) => {
568
654
  if (this.outputUpdateHandler) {
@@ -575,103 +661,142 @@ export class CoreToolScheduler {
575
661
  }
576
662
  : undefined;
577
663
  const shellExecutionConfig = this.config.getShellExecutionConfig();
578
- // TODO: Refactor to remove special casing for ShellToolInvocation.
579
- // Introduce a generic callbacks object for the execute method to handle
580
- // things like `onPid` and `onLiveOutput`. This will make the scheduler
581
- // agnostic to the invocation type.
582
- let promise;
583
- if (invocation instanceof ShellToolInvocation) {
584
- const setPidCallback = (pid) => {
585
- this.toolCalls = this.toolCalls.map((tc) => tc.request.callId === callId && tc.status === 'executing'
586
- ? { ...tc, pid }
587
- : tc);
588
- this.notifyToolCallsUpdate();
664
+ await runInDevTraceSpan({
665
+ name: toolCall.tool.name,
666
+ attributes: { type: 'tool-call' },
667
+ }, async ({ metadata: spanMetadata }) => {
668
+ spanMetadata.input = {
669
+ request: toolCall.request,
589
670
  };
590
- promise = invocation.execute(signal, liveOutputCallback, shellExecutionConfig, setPidCallback);
591
- }
592
- else {
593
- promise = invocation.execute(signal, liveOutputCallback, shellExecutionConfig);
594
- }
595
- promise
596
- .then(async (toolResult) => {
597
- if (signal.aborted) {
598
- this.setStatusInternal(callId, 'cancelled', 'User cancelled tool execution.');
599
- return;
600
- }
601
- if (toolResult.error === undefined) {
602
- let content = toolResult.llmContent;
603
- let outputFile = undefined;
604
- const contentLength = typeof content === 'string' ? content.length : undefined;
605
- if (typeof content === 'string' &&
606
- toolName === ShellTool.Name &&
607
- this.config.getEnableToolOutputTruncation() &&
608
- this.config.getTruncateToolOutputThreshold() > 0 &&
609
- this.config.getTruncateToolOutputLines() > 0) {
610
- const originalContentLength = content.length;
611
- const threshold = this.config.getTruncateToolOutputThreshold();
612
- const lines = this.config.getTruncateToolOutputLines();
613
- const truncatedResult = await truncateAndSaveToFile(content, callId, this.config.storage.getProjectTempDir(), threshold, lines);
614
- content = truncatedResult.content;
615
- outputFile = truncatedResult.outputFile;
616
- if (outputFile) {
617
- logToolOutputTruncated(this.config, new ToolOutputTruncatedEvent(scheduledCall.request.prompt_id, {
618
- toolName,
619
- originalContentLength,
620
- truncatedContentLength: content.length,
621
- threshold,
622
- lines,
623
- }));
624
- }
625
- }
626
- const response = convertToFunctionResponse(toolName, callId, content);
627
- const successResponse = {
628
- callId,
629
- responseParts: response,
630
- resultDisplay: toolResult.returnDisplay,
631
- error: undefined,
632
- errorType: undefined,
633
- outputFile,
634
- contentLength,
671
+ // TODO: Refactor to remove special casing for ShellToolInvocation.
672
+ // Introduce a generic callbacks object for the execute method to handle
673
+ // things like `onPid` and `onLiveOutput`. This will make the scheduler
674
+ // agnostic to the invocation type.
675
+ let promise;
676
+ if (invocation instanceof ShellToolInvocation) {
677
+ const setPidCallback = (pid) => {
678
+ this.toolCalls = this.toolCalls.map((tc) => tc.request.callId === callId && tc.status === 'executing'
679
+ ? { ...tc, pid }
680
+ : tc);
681
+ this.notifyToolCallsUpdate();
635
682
  };
636
- this.setStatusInternal(callId, 'success', successResponse);
683
+ promise = invocation.execute(signal, liveOutputCallback, shellExecutionConfig, setPidCallback);
637
684
  }
638
685
  else {
639
- // It is a failure
640
- const error = new Error(toolResult.error.message);
641
- const errorResponse = createErrorResponse(scheduledCall.request, error, toolResult.error.type);
642
- this.setStatusInternal(callId, 'error', errorResponse);
686
+ promise = invocation.execute(signal, liveOutputCallback, shellExecutionConfig);
643
687
  }
644
- })
645
- .catch((executionError) => {
646
- if (signal.aborted) {
647
- this.setStatusInternal(callId, 'cancelled', 'User cancelled tool execution.');
688
+ try {
689
+ const toolResult = await promise;
690
+ spanMetadata.output = toolResult;
691
+ if (signal.aborted) {
692
+ this.setStatusInternal(callId, 'cancelled', signal, 'User cancelled tool execution.');
693
+ }
694
+ else if (toolResult.error === undefined) {
695
+ let content = toolResult.llmContent;
696
+ let outputFile = undefined;
697
+ const contentLength = typeof content === 'string' ? content.length : undefined;
698
+ if (typeof content === 'string' &&
699
+ toolName === SHELL_TOOL_NAME &&
700
+ this.config.getEnableToolOutputTruncation() &&
701
+ this.config.getTruncateToolOutputThreshold() > 0 &&
702
+ this.config.getTruncateToolOutputLines() > 0) {
703
+ const originalContentLength = content.length;
704
+ const threshold = this.config.getTruncateToolOutputThreshold();
705
+ const lines = this.config.getTruncateToolOutputLines();
706
+ const truncatedResult = await truncateAndSaveToFile(content, callId, this.config.storage.getProjectTempDir(), threshold, lines);
707
+ content = truncatedResult.content;
708
+ outputFile = truncatedResult.outputFile;
709
+ if (outputFile) {
710
+ logToolOutputTruncated(this.config, new ToolOutputTruncatedEvent(scheduledCall.request.prompt_id, {
711
+ toolName,
712
+ originalContentLength,
713
+ truncatedContentLength: content.length,
714
+ threshold,
715
+ lines,
716
+ }));
717
+ }
718
+ }
719
+ const response = convertToFunctionResponse(toolName, callId, content);
720
+ const successResponse = {
721
+ callId,
722
+ responseParts: response,
723
+ resultDisplay: toolResult.returnDisplay,
724
+ error: undefined,
725
+ errorType: undefined,
726
+ outputFile,
727
+ contentLength,
728
+ };
729
+ this.setStatusInternal(callId, 'success', signal, successResponse);
730
+ }
731
+ else {
732
+ // It is a failure
733
+ const error = new Error(toolResult.error.message);
734
+ const errorResponse = createErrorResponse(scheduledCall.request, error, toolResult.error.type);
735
+ this.setStatusInternal(callId, 'error', signal, errorResponse);
736
+ }
648
737
  }
649
- else {
650
- this.setStatusInternal(callId, 'error', createErrorResponse(scheduledCall.request, executionError instanceof Error
651
- ? executionError
652
- : new Error(String(executionError)), ToolErrorType.UNHANDLED_EXCEPTION));
738
+ catch (executionError) {
739
+ spanMetadata.error = executionError;
740
+ if (signal.aborted) {
741
+ this.setStatusInternal(callId, 'cancelled', signal, 'User cancelled tool execution.');
742
+ }
743
+ else {
744
+ this.setStatusInternal(callId, 'error', signal, createErrorResponse(scheduledCall.request, executionError instanceof Error
745
+ ? executionError
746
+ : new Error(String(executionError)), ToolErrorType.UNHANDLED_EXCEPTION));
747
+ }
653
748
  }
749
+ await this.checkAndNotifyCompletion(signal);
654
750
  });
655
- });
751
+ }
656
752
  }
657
753
  }
658
- async checkAndNotifyCompletion() {
659
- const allCallsAreTerminal = this.toolCalls.every((call) => call.status === 'success' ||
660
- call.status === 'error' ||
661
- call.status === 'cancelled');
662
- if (this.toolCalls.length > 0 && allCallsAreTerminal) {
663
- const completedCalls = [...this.toolCalls];
754
+ async checkAndNotifyCompletion(signal) {
755
+ // This method is now only concerned with the single active tool call.
756
+ if (this.toolCalls.length === 0) {
757
+ // It's possible to be called when a batch is cancelled before any tool has started.
758
+ if (signal.aborted && this.toolCallQueue.length > 0) {
759
+ this._cancelAllQueuedCalls();
760
+ }
761
+ }
762
+ else {
763
+ const activeCall = this.toolCalls[0];
764
+ const isTerminal = activeCall.status === 'success' ||
765
+ activeCall.status === 'error' ||
766
+ activeCall.status === 'cancelled';
767
+ // If the active tool is not in a terminal state (e.g., it's 'executing' or 'awaiting_approval'),
768
+ // then the scheduler is still busy or paused. We should not proceed.
769
+ if (!isTerminal) {
770
+ return;
771
+ }
772
+ // The active tool is finished. Move it to the completed batch.
773
+ const completedCall = activeCall;
774
+ this.completedToolCallsForBatch.push(completedCall);
775
+ logToolCall(this.config, new ToolCallEvent(completedCall));
776
+ // Clear the active tool slot. This is crucial for the sequential processing.
664
777
  this.toolCalls = [];
665
- for (const call of completedCalls) {
666
- logToolCall(this.config, new ToolCallEvent(call));
778
+ }
779
+ // Now, check if the entire batch is complete.
780
+ // The batch is complete if the queue is empty or the operation was cancelled.
781
+ if (this.toolCallQueue.length === 0 || signal.aborted) {
782
+ if (signal.aborted) {
783
+ this._cancelAllQueuedCalls();
784
+ }
785
+ // If there's nothing to report and we weren't cancelled, we can stop.
786
+ // But if we were cancelled, we must proceed to potentially start the next queued request.
787
+ if (this.completedToolCallsForBatch.length === 0 && !signal.aborted) {
788
+ return;
667
789
  }
668
790
  if (this.onAllToolCallsComplete) {
669
791
  this.isFinalizingToolCalls = true;
670
- await this.onAllToolCallsComplete(completedCalls);
792
+ // Use the batch array, not the (now empty) active array.
793
+ await this.onAllToolCallsComplete(this.completedToolCallsForBatch);
794
+ this.completedToolCallsForBatch = []; // Clear after reporting.
671
795
  this.isFinalizingToolCalls = false;
672
796
  }
797
+ this.isCancelling = false;
673
798
  this.notifyToolCallsUpdate();
674
- // After completion, process the next item in the queue.
799
+ // After completion of the entire batch, process the next item in the main request queue.
675
800
  if (this.requestQueue.length > 0) {
676
801
  const next = this.requestQueue.shift();
677
802
  this._schedule(next.request, next.signal)
@@ -679,10 +804,58 @@ export class CoreToolScheduler {
679
804
  .catch(next.reject);
680
805
  }
681
806
  }
807
+ else {
808
+ // The batch is not yet complete, so continue processing the current batch sequence.
809
+ await this._processNextInQueue(signal);
810
+ }
811
+ }
812
+ _cancelAllQueuedCalls() {
813
+ while (this.toolCallQueue.length > 0) {
814
+ const queuedCall = this.toolCallQueue.shift();
815
+ // Don't cancel tools that already errored during validation.
816
+ if (queuedCall.status === 'error') {
817
+ this.completedToolCallsForBatch.push(queuedCall);
818
+ continue;
819
+ }
820
+ const durationMs = 'startTime' in queuedCall && queuedCall.startTime
821
+ ? Date.now() - queuedCall.startTime
822
+ : undefined;
823
+ const errorMessage = '[Operation Cancelled] User cancelled the operation.';
824
+ this.completedToolCallsForBatch.push({
825
+ request: queuedCall.request,
826
+ tool: queuedCall.tool,
827
+ invocation: queuedCall.invocation,
828
+ status: 'cancelled',
829
+ response: {
830
+ callId: queuedCall.request.callId,
831
+ responseParts: [
832
+ {
833
+ functionResponse: {
834
+ id: queuedCall.request.callId,
835
+ name: queuedCall.request.name,
836
+ response: {
837
+ error: errorMessage,
838
+ },
839
+ },
840
+ },
841
+ ],
842
+ resultDisplay: undefined,
843
+ error: undefined,
844
+ errorType: undefined,
845
+ contentLength: errorMessage.length,
846
+ },
847
+ durationMs,
848
+ outcome: ToolConfirmationOutcome.Cancel,
849
+ });
850
+ }
682
851
  }
683
852
  notifyToolCallsUpdate() {
684
853
  if (this.onToolCallsUpdate) {
685
- this.onToolCallsUpdate([...this.toolCalls]);
854
+ this.onToolCallsUpdate([
855
+ ...this.completedToolCallsForBatch,
856
+ ...this.toolCalls,
857
+ ...this.toolCallQueue,
858
+ ]);
686
859
  }
687
860
  }
688
861
  setToolCallOutcome(callId, outcome) {
@@ -695,21 +868,17 @@ export class CoreToolScheduler {
695
868
  };
696
869
  });
697
870
  }
698
- async autoApproveCompatiblePendingTools(signal, triggeringCallId) {
699
- const pendingTools = this.toolCalls.filter((call) => call.status === 'awaiting_approval' &&
700
- call.request.callId !== triggeringCallId);
701
- for (const pendingTool of pendingTools) {
702
- try {
703
- const stillNeedsConfirmation = await pendingTool.invocation.shouldConfirmExecute(signal);
704
- if (!stillNeedsConfirmation) {
705
- this.setToolCallOutcome(pendingTool.request.callId, ToolConfirmationOutcome.ProceedAlways);
706
- this.setStatusInternal(pendingTool.request.callId, 'scheduled');
707
- }
708
- }
709
- catch (error) {
710
- console.error(`Error checking confirmation for tool ${pendingTool.request.callId}:`, error);
711
- }
871
+ isAutoApproved(toolCall) {
872
+ if (this.config.getApprovalMode() === ApprovalMode.YOLO) {
873
+ return true;
874
+ }
875
+ const allowedTools = this.config.getAllowedTools() || [];
876
+ const { tool, invocation } = toolCall;
877
+ const toolName = typeof tool === 'string' ? tool : tool.name;
878
+ if (SHELL_TOOL_NAMES.includes(toolName)) {
879
+ return isShellInvocationAllowlisted(invocation, allowedTools);
712
880
  }
881
+ return doesToolInvocationMatch(tool, invocation, allowedTools);
713
882
  }
714
883
  }
715
884
  //# sourceMappingURL=coreToolScheduler.js.map