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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.js +3 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +9 -2
  5. package/dist/src/code_assist/converter.d.ts +4 -2
  6. package/dist/src/code_assist/converter.js +2 -1
  7. package/dist/src/code_assist/converter.js.map +1 -1
  8. package/dist/src/code_assist/converter.test.js +48 -1
  9. package/dist/src/code_assist/converter.test.js.map +1 -1
  10. package/dist/src/code_assist/oauth2.d.ts +1 -0
  11. package/dist/src/code_assist/oauth2.js +38 -21
  12. package/dist/src/code_assist/oauth2.js.map +1 -1
  13. package/dist/src/code_assist/oauth2.test.js +51 -8
  14. package/dist/src/code_assist/oauth2.test.js.map +1 -1
  15. package/dist/src/code_assist/server.js +1 -1
  16. package/dist/src/code_assist/server.js.map +1 -1
  17. package/dist/src/code_assist/server.test.js +4 -1
  18. package/dist/src/code_assist/server.test.js.map +1 -1
  19. package/dist/src/code_assist/setup.js +48 -17
  20. package/dist/src/code_assist/setup.js.map +1 -1
  21. package/dist/src/code_assist/setup.test.js +114 -8
  22. package/dist/src/code_assist/setup.test.js.map +1 -1
  23. package/dist/src/config/config.d.ts +41 -11
  24. package/dist/src/config/config.js +85 -27
  25. package/dist/src/config/config.js.map +1 -1
  26. package/dist/src/config/config.test.js +117 -3
  27. package/dist/src/config/config.test.js.map +1 -1
  28. package/dist/src/config/flashFallback.test.js +0 -4
  29. package/dist/src/config/flashFallback.test.js.map +1 -1
  30. package/dist/src/core/client.d.ts +12 -16
  31. package/dist/src/core/client.js +218 -135
  32. package/dist/src/core/client.js.map +1 -1
  33. package/dist/src/core/client.test.js +636 -37
  34. package/dist/src/core/client.test.js.map +1 -1
  35. package/dist/src/core/contentGenerator.js +23 -21
  36. package/dist/src/core/contentGenerator.js.map +1 -1
  37. package/dist/src/core/contentGenerator.test.js +30 -126
  38. package/dist/src/core/contentGenerator.test.js.map +1 -1
  39. package/dist/src/core/coreToolScheduler.d.ts +23 -8
  40. package/dist/src/core/coreToolScheduler.js +179 -64
  41. package/dist/src/core/coreToolScheduler.js.map +1 -1
  42. package/dist/src/core/coreToolScheduler.test.js +250 -97
  43. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  44. package/dist/src/core/geminiChat.d.ts +7 -6
  45. package/dist/src/core/geminiChat.js +43 -43
  46. package/dist/src/core/geminiChat.js.map +1 -1
  47. package/dist/src/core/logger.d.ts +23 -1
  48. package/dist/src/core/logger.js +115 -11
  49. package/dist/src/core/logger.js.map +1 -1
  50. package/dist/src/core/logger.test.js +112 -17
  51. package/dist/src/core/logger.test.js.map +1 -1
  52. package/dist/src/core/loggingContentGenerator.d.ts +25 -0
  53. package/dist/src/core/loggingContentGenerator.js +95 -0
  54. package/dist/src/core/loggingContentGenerator.js.map +1 -0
  55. package/dist/src/core/nonInteractiveToolExecutor.js +28 -1
  56. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  57. package/dist/src/core/nonInteractiveToolExecutor.test.js +85 -62
  58. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  59. package/dist/src/core/prompts.js +4 -4
  60. package/dist/src/core/prompts.js.map +1 -1
  61. package/dist/src/core/subagent.d.ts +230 -0
  62. package/dist/src/core/subagent.js +447 -0
  63. package/dist/src/core/subagent.js.map +1 -0
  64. package/dist/src/core/subagent.test.d.ts +6 -0
  65. package/dist/src/core/subagent.test.js +515 -0
  66. package/dist/src/core/subagent.test.js.map +1 -0
  67. package/dist/src/core/turn.js +1 -0
  68. package/dist/src/core/turn.js.map +1 -1
  69. package/dist/src/core/turn.test.js +4 -0
  70. package/dist/src/core/turn.test.js.map +1 -1
  71. package/dist/src/generated/git-commit.d.ts +7 -0
  72. package/dist/src/generated/git-commit.js +10 -0
  73. package/dist/src/generated/git-commit.js.map +1 -0
  74. package/dist/src/ide/constants.d.ts +6 -0
  75. package/dist/src/ide/constants.js +7 -0
  76. package/dist/src/ide/constants.js.map +1 -0
  77. package/dist/src/ide/detect-ide.d.ts +12 -2
  78. package/dist/src/ide/detect-ide.js +64 -5
  79. package/dist/src/ide/detect-ide.js.map +1 -1
  80. package/dist/src/ide/detect-ide.test.d.ts +6 -0
  81. package/dist/src/ide/detect-ide.test.js +65 -0
  82. package/dist/src/ide/detect-ide.test.js.map +1 -0
  83. package/dist/src/ide/ide-client.d.ts +34 -11
  84. package/dist/src/ide/ide-client.js +230 -62
  85. package/dist/src/ide/ide-client.js.map +1 -1
  86. package/dist/src/ide/ide-client.test.d.ts +6 -0
  87. package/dist/src/ide/ide-client.test.js +43 -0
  88. package/dist/src/ide/ide-client.test.js.map +1 -0
  89. package/dist/src/ide/ide-installer.js +23 -34
  90. package/dist/src/ide/ide-installer.js.map +1 -1
  91. package/dist/src/ide/ide-installer.test.js +6 -8
  92. package/dist/src/ide/ide-installer.test.js.map +1 -1
  93. package/dist/src/ide/ideContext.d.ts +97 -2
  94. package/dist/src/ide/ideContext.js +45 -0
  95. package/dist/src/ide/ideContext.js.map +1 -1
  96. package/dist/src/ide/process-utils.d.ts +14 -0
  97. package/dist/src/ide/process-utils.js +57 -0
  98. package/dist/src/ide/process-utils.js.map +1 -0
  99. package/dist/src/index.d.ts +7 -1
  100. package/dist/src/index.js +7 -1
  101. package/dist/src/index.js.map +1 -1
  102. package/dist/src/mcp/google-auth-provider.js +9 -0
  103. package/dist/src/mcp/google-auth-provider.js.map +1 -1
  104. package/dist/src/mcp/google-auth-provider.test.js +45 -10
  105. package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
  106. package/dist/src/mcp/oauth-provider.d.ts +1 -1
  107. package/dist/src/mcp/oauth-provider.js +185 -59
  108. package/dist/src/mcp/oauth-provider.js.map +1 -1
  109. package/dist/src/mcp/oauth-provider.test.js +134 -62
  110. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  111. package/dist/src/mcp/oauth-utils.d.ts +3 -1
  112. package/dist/src/mcp/oauth-utils.js +50 -12
  113. package/dist/src/mcp/oauth-utils.js.map +1 -1
  114. package/dist/src/mcp/oauth-utils.test.js +17 -2
  115. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  116. package/dist/src/mocks/msw.d.ts +6 -0
  117. package/dist/src/mocks/msw.js +8 -0
  118. package/dist/src/mocks/msw.js.map +1 -0
  119. package/dist/src/prompts/prompt-registry.d.ts +8 -0
  120. package/dist/src/prompts/prompt-registry.js +16 -0
  121. package/dist/src/prompts/prompt-registry.js.map +1 -1
  122. package/dist/src/services/chatRecordingService.d.ts +150 -0
  123. package/dist/src/services/chatRecordingService.js +318 -0
  124. package/dist/src/services/chatRecordingService.js.map +1 -0
  125. package/dist/src/services/chatRecordingService.test.d.ts +6 -0
  126. package/dist/src/services/chatRecordingService.test.js +288 -0
  127. package/dist/src/services/chatRecordingService.test.js.map +1 -0
  128. package/dist/src/services/fileSystemService.d.ts +31 -0
  129. package/dist/src/services/fileSystemService.js +18 -0
  130. package/dist/src/services/fileSystemService.js.map +1 -0
  131. package/dist/src/services/fileSystemService.test.d.ts +6 -0
  132. package/dist/src/services/fileSystemService.test.js +41 -0
  133. package/dist/src/services/fileSystemService.test.js.map +1 -0
  134. package/dist/src/services/loopDetectionService.js +19 -16
  135. package/dist/src/services/loopDetectionService.js.map +1 -1
  136. package/dist/src/services/loopDetectionService.test.js +191 -0
  137. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  138. package/dist/src/services/shellExecutionService.js +29 -9
  139. package/dist/src/services/shellExecutionService.js.map +1 -1
  140. package/dist/src/services/shellExecutionService.test.js +21 -3
  141. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  142. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +78 -9
  143. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +316 -205
  144. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  145. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +17 -0
  146. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +342 -0
  147. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -0
  148. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +14 -2
  149. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +32 -9
  150. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  151. package/dist/src/telemetry/constants.d.ts +2 -0
  152. package/dist/src/telemetry/constants.js +2 -0
  153. package/dist/src/telemetry/constants.js.map +1 -1
  154. package/dist/src/telemetry/index.d.ts +2 -2
  155. package/dist/src/telemetry/index.js +2 -2
  156. package/dist/src/telemetry/index.js.map +1 -1
  157. package/dist/src/telemetry/integration.test.circular.js +1 -0
  158. package/dist/src/telemetry/integration.test.circular.js.map +1 -1
  159. package/dist/src/telemetry/loggers.d.ts +4 -1
  160. package/dist/src/telemetry/loggers.js +55 -6
  161. package/dist/src/telemetry/loggers.js.map +1 -1
  162. package/dist/src/telemetry/loggers.test.circular.js +7 -2
  163. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  164. package/dist/src/telemetry/loggers.test.js +43 -8
  165. package/dist/src/telemetry/loggers.test.js.map +1 -1
  166. package/dist/src/telemetry/metrics.d.ts +7 -2
  167. package/dist/src/telemetry/metrics.js +26 -6
  168. package/dist/src/telemetry/metrics.js.map +1 -1
  169. package/dist/src/telemetry/metrics.test.js +81 -1
  170. package/dist/src/telemetry/metrics.test.js.map +1 -1
  171. package/dist/src/telemetry/sdk.d.ts +1 -1
  172. package/dist/src/telemetry/sdk.js +77 -41
  173. package/dist/src/telemetry/sdk.js.map +1 -1
  174. package/dist/src/telemetry/sdk.test.d.ts +6 -0
  175. package/dist/src/telemetry/sdk.test.js +82 -0
  176. package/dist/src/telemetry/sdk.test.js.map +1 -0
  177. package/dist/src/telemetry/telemetry.test.js +2 -4
  178. package/dist/src/telemetry/telemetry.test.js.map +1 -1
  179. package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
  180. package/dist/src/telemetry/tool-call-decision.js +29 -0
  181. package/dist/src/telemetry/tool-call-decision.js.map +1 -0
  182. package/dist/src/telemetry/types.d.ts +55 -21
  183. package/dist/src/telemetry/types.js +83 -43
  184. package/dist/src/telemetry/types.js.map +1 -1
  185. package/dist/src/telemetry/uiTelemetry.d.ts +8 -1
  186. package/dist/src/telemetry/uiTelemetry.js +17 -2
  187. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  188. package/dist/src/telemetry/uiTelemetry.test.js +57 -10
  189. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  190. package/dist/src/test-utils/config.d.ts +16 -0
  191. package/dist/src/test-utils/config.js +32 -0
  192. package/dist/src/test-utils/config.js.map +1 -0
  193. package/dist/src/test-utils/tools.d.ts +44 -0
  194. package/dist/src/test-utils/tools.js +105 -0
  195. package/dist/src/test-utils/tools.js.map +1 -0
  196. package/dist/src/tools/diffOptions.d.ts +2 -0
  197. package/dist/src/tools/diffOptions.js +28 -0
  198. package/dist/src/tools/diffOptions.js.map +1 -1
  199. package/dist/src/tools/diffOptions.test.d.ts +6 -0
  200. package/dist/src/tools/diffOptions.test.js +119 -0
  201. package/dist/src/tools/diffOptions.test.js.map +1 -0
  202. package/dist/src/tools/edit.d.ts +10 -34
  203. package/dist/src/tools/edit.js +152 -136
  204. package/dist/src/tools/edit.js.map +1 -1
  205. package/dist/src/tools/edit.test.js +125 -51
  206. package/dist/src/tools/edit.test.js.map +1 -1
  207. package/dist/src/tools/glob.d.ts +4 -11
  208. package/dist/src/tools/glob.js +87 -91
  209. package/dist/src/tools/glob.js.map +1 -1
  210. package/dist/src/tools/glob.test.js +42 -12
  211. package/dist/src/tools/glob.test.js.map +1 -1
  212. package/dist/src/tools/grep.d.ts +4 -36
  213. package/dist/src/tools/grep.js +107 -84
  214. package/dist/src/tools/grep.js.map +1 -1
  215. package/dist/src/tools/grep.test.js +40 -23
  216. package/dist/src/tools/grep.test.js.map +1 -1
  217. package/dist/src/tools/ls.d.ts +4 -23
  218. package/dist/src/tools/ls.js +77 -79
  219. package/dist/src/tools/ls.js.map +1 -1
  220. package/dist/src/tools/ls.test.js +62 -34
  221. package/dist/src/tools/ls.test.js.map +1 -1
  222. package/dist/src/tools/mcp-client-manager.d.ts +38 -0
  223. package/dist/src/tools/mcp-client-manager.js +74 -0
  224. package/dist/src/tools/mcp-client-manager.js.map +1 -0
  225. package/dist/src/tools/mcp-client-manager.test.d.ts +6 -0
  226. package/dist/src/tools/mcp-client-manager.test.js +39 -0
  227. package/dist/src/tools/mcp-client-manager.test.js.map +1 -0
  228. package/dist/src/tools/mcp-client.d.ts +57 -3
  229. package/dist/src/tools/mcp-client.js +235 -10
  230. package/dist/src/tools/mcp-client.js.map +1 -1
  231. package/dist/src/tools/mcp-client.test.js +234 -87
  232. package/dist/src/tools/mcp-client.test.js.map +1 -1
  233. package/dist/src/tools/mcp-tool.d.ts +6 -13
  234. package/dist/src/tools/mcp-tool.js +62 -34
  235. package/dist/src/tools/mcp-tool.js.map +1 -1
  236. package/dist/src/tools/mcp-tool.test.js +118 -59
  237. package/dist/src/tools/mcp-tool.test.js.map +1 -1
  238. package/dist/src/tools/memoryTool.d.ts +10 -14
  239. package/dist/src/tools/memoryTool.js +123 -121
  240. package/dist/src/tools/memoryTool.js.map +1 -1
  241. package/dist/src/tools/memoryTool.test.js +38 -18
  242. package/dist/src/tools/memoryTool.test.js.map +1 -1
  243. package/dist/src/tools/modifiable-tool.d.ts +9 -6
  244. package/dist/src/tools/modifiable-tool.js +6 -3
  245. package/dist/src/tools/modifiable-tool.js.map +1 -1
  246. package/dist/src/tools/modifiable-tool.test.js +12 -12
  247. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  248. package/dist/src/tools/read-file.d.ts +4 -6
  249. package/dist/src/tools/read-file.js +95 -50
  250. package/dist/src/tools/read-file.js.map +1 -1
  251. package/dist/src/tools/read-file.test.js +199 -129
  252. package/dist/src/tools/read-file.test.js.map +1 -1
  253. package/dist/src/tools/read-many-files.d.ts +3 -5
  254. package/dist/src/tools/read-many-files.js +204 -138
  255. package/dist/src/tools/read-many-files.js.map +1 -1
  256. package/dist/src/tools/read-many-files.test.js +197 -33
  257. package/dist/src/tools/read-many-files.test.js.map +1 -1
  258. package/dist/src/tools/shell.d.ts +4 -6
  259. package/dist/src/tools/shell.js +112 -102
  260. package/dist/src/tools/shell.js.map +1 -1
  261. package/dist/src/tools/shell.test.js +55 -28
  262. package/dist/src/tools/shell.test.js.map +1 -1
  263. package/dist/src/tools/tool-error.d.ts +5 -0
  264. package/dist/src/tools/tool-error.js +5 -0
  265. package/dist/src/tools/tool-error.js.map +1 -1
  266. package/dist/src/tools/tool-registry.d.ts +25 -22
  267. package/dist/src/tools/tool-registry.js +100 -116
  268. package/dist/src/tools/tool-registry.js.map +1 -1
  269. package/dist/src/tools/tool-registry.test.js +29 -212
  270. package/dist/src/tools/tool-registry.test.js.map +1 -1
  271. package/dist/src/tools/tools.d.ts +137 -92
  272. package/dist/src/tools/tools.js +188 -61
  273. package/dist/src/tools/tools.js.map +1 -1
  274. package/dist/src/tools/tools.test.d.ts +6 -0
  275. package/dist/src/tools/tools.test.js +206 -0
  276. package/dist/src/tools/tools.test.js.map +1 -0
  277. package/dist/src/tools/web-fetch.d.ts +4 -7
  278. package/dist/src/tools/web-fetch.js +58 -64
  279. package/dist/src/tools/web-fetch.js.map +1 -1
  280. package/dist/src/tools/web-fetch.test.js +8 -4
  281. package/dist/src/tools/web-fetch.test.js.map +1 -1
  282. package/dist/src/tools/web-search.d.ts +4 -5
  283. package/dist/src/tools/web-search.js +47 -51
  284. package/dist/src/tools/web-search.js.map +1 -1
  285. package/dist/src/tools/web-search.test.d.ts +6 -0
  286. package/dist/src/tools/web-search.test.js +139 -0
  287. package/dist/src/tools/web-search.test.js.map +1 -0
  288. package/dist/src/tools/write-file.d.ts +20 -11
  289. package/dist/src/tools/write-file.js +197 -142
  290. package/dist/src/tools/write-file.js.map +1 -1
  291. package/dist/src/tools/write-file.test.js +156 -96
  292. package/dist/src/tools/write-file.test.js.map +1 -1
  293. package/dist/src/utils/bfsFileSearch.test.js +28 -56
  294. package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
  295. package/dist/src/utils/browser.js +4 -3
  296. package/dist/src/utils/browser.js.map +1 -1
  297. package/dist/src/utils/editCorrector.js +21 -22
  298. package/dist/src/utils/editCorrector.js.map +1 -1
  299. package/dist/src/utils/editor.d.ts +1 -1
  300. package/dist/src/utils/editor.js +14 -6
  301. package/dist/src/utils/editor.js.map +1 -1
  302. package/dist/src/utils/editor.test.js +48 -16
  303. package/dist/src/utils/editor.test.js.map +1 -1
  304. package/dist/src/utils/environmentContext.d.ts +21 -0
  305. package/dist/src/utils/environmentContext.js +90 -0
  306. package/dist/src/utils/environmentContext.js.map +1 -0
  307. package/dist/src/utils/environmentContext.test.d.ts +6 -0
  308. package/dist/src/utils/environmentContext.test.js +140 -0
  309. package/dist/src/utils/environmentContext.test.js.map +1 -0
  310. package/dist/src/utils/errorParsing.d.ts +8 -0
  311. package/dist/src/utils/errorParsing.js +93 -0
  312. package/dist/src/utils/errorParsing.js.map +1 -0
  313. package/dist/src/utils/errorParsing.test.d.ts +6 -0
  314. package/dist/src/utils/errorParsing.test.js +172 -0
  315. package/dist/src/utils/errorParsing.test.js.map +1 -0
  316. package/dist/src/utils/fileUtils.d.ts +9 -1
  317. package/dist/src/utils/fileUtils.js +18 -15
  318. package/dist/src/utils/fileUtils.js.map +1 -1
  319. package/dist/src/utils/fileUtils.test.js +24 -22
  320. package/dist/src/utils/fileUtils.test.js.map +1 -1
  321. package/dist/src/utils/filesearch/crawlCache.d.ts +25 -0
  322. package/dist/src/utils/filesearch/crawlCache.js +57 -0
  323. package/dist/src/utils/filesearch/crawlCache.js.map +1 -0
  324. package/dist/src/utils/filesearch/crawlCache.test.d.ts +6 -0
  325. package/dist/src/utils/filesearch/crawlCache.test.js +103 -0
  326. package/dist/src/utils/filesearch/crawlCache.test.js.map +1 -0
  327. package/dist/src/utils/filesearch/crawler.d.ts +15 -0
  328. package/dist/src/utils/filesearch/crawler.js +50 -0
  329. package/dist/src/utils/filesearch/crawler.js.map +1 -0
  330. package/dist/src/utils/filesearch/crawler.test.d.ts +6 -0
  331. package/dist/src/utils/filesearch/crawler.test.js +468 -0
  332. package/dist/src/utils/filesearch/crawler.test.js.map +1 -0
  333. package/dist/src/utils/filesearch/fileSearch.d.ts +37 -0
  334. package/dist/src/utils/filesearch/fileSearch.js +186 -0
  335. package/dist/src/utils/filesearch/fileSearch.js.map +1 -0
  336. package/dist/src/utils/filesearch/fileSearch.test.d.ts +6 -0
  337. package/dist/src/utils/filesearch/fileSearch.test.js +552 -0
  338. package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -0
  339. package/dist/src/utils/filesearch/ignore.d.ts +42 -0
  340. package/dist/src/utils/filesearch/ignore.js +106 -0
  341. package/dist/src/utils/filesearch/ignore.js.map +1 -0
  342. package/dist/src/utils/filesearch/ignore.test.d.ts +6 -0
  343. package/dist/src/utils/filesearch/ignore.test.js +144 -0
  344. package/dist/src/utils/filesearch/ignore.test.js.map +1 -0
  345. package/dist/src/utils/filesearch/result-cache.d.ts +33 -0
  346. package/dist/src/utils/filesearch/result-cache.js +59 -0
  347. package/dist/src/utils/filesearch/result-cache.js.map +1 -0
  348. package/dist/src/utils/filesearch/result-cache.test.d.ts +6 -0
  349. package/dist/src/utils/filesearch/result-cache.test.js +46 -0
  350. package/dist/src/utils/filesearch/result-cache.test.js.map +1 -0
  351. package/dist/src/utils/flashFallback.integration.test.js +0 -2
  352. package/dist/src/utils/flashFallback.integration.test.js.map +1 -1
  353. package/dist/src/utils/memoryDiscovery.js +7 -4
  354. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  355. package/dist/src/utils/memoryDiscovery.test.js +3 -2
  356. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  357. package/dist/src/utils/memoryImportProcessor.js +3 -7
  358. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  359. package/dist/src/utils/memoryImportProcessor.test.js +17 -20
  360. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  361. package/dist/src/utils/nextSpeakerChecker.js +5 -6
  362. package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
  363. package/dist/src/utils/nextSpeakerChecker.test.js +2 -2
  364. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  365. package/dist/src/utils/paths.d.ts +7 -0
  366. package/dist/src/utils/paths.js +15 -0
  367. package/dist/src/utils/paths.js.map +1 -1
  368. package/dist/src/utils/paths.test.js +74 -2
  369. package/dist/src/utils/paths.test.js.map +1 -1
  370. package/dist/src/utils/quotaErrorDetection.d.ts +1 -5
  371. package/dist/src/utils/quotaErrorDetection.js.map +1 -1
  372. package/dist/src/utils/schemaValidator.d.ts +1 -8
  373. package/dist/src/utils/schemaValidator.js +1 -32
  374. package/dist/src/utils/schemaValidator.js.map +1 -1
  375. package/dist/src/utils/secure-browser-launcher.js +4 -3
  376. package/dist/src/utils/secure-browser-launcher.js.map +1 -1
  377. package/dist/src/utils/shell-utils.d.ts +39 -0
  378. package/dist/src/utils/shell-utils.js +72 -2
  379. package/dist/src/utils/shell-utils.js.map +1 -1
  380. package/dist/src/utils/shell-utils.test.js +132 -4
  381. package/dist/src/utils/shell-utils.test.js.map +1 -1
  382. package/dist/src/utils/systemEncoding.js +1 -1
  383. package/dist/src/utils/systemEncoding.js.map +1 -1
  384. package/dist/src/utils/systemEncoding.test.js +23 -23
  385. package/dist/src/utils/systemEncoding.test.js.map +1 -1
  386. package/dist/src/utils/user_account.js +58 -48
  387. package/dist/src/utils/user_account.js.map +1 -1
  388. package/dist/src/utils/user_account.test.js +76 -9
  389. package/dist/src/utils/user_account.test.js.map +1 -1
  390. package/dist/src/utils/workspaceContext.d.ts +22 -7
  391. package/dist/src/utils/workspaceContext.js +81 -55
  392. package/dist/src/utils/workspaceContext.js.map +1 -1
  393. package/dist/src/utils/workspaceContext.test.js +221 -137
  394. package/dist/src/utils/workspaceContext.test.js.map +1 -1
  395. package/dist/tsconfig.tsbuildinfo +1 -1
  396. package/package.json +13 -3
  397. package/dist/src/core/modelCheck.d.ts +0 -14
  398. package/dist/src/core/modelCheck.js +0 -62
  399. package/dist/src/core/modelCheck.js.map +0 -1
@@ -3,136 +3,165 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { FunctionDeclaration, PartListUnion, Schema } from '@google/genai';
6
+ import { FunctionDeclaration, PartListUnion } from '@google/genai';
7
7
  import { ToolErrorType } from './tool-error.js';
8
+ import { DiffUpdateResult } from '../ide/ideContext.js';
8
9
  /**
9
- * Interface representing the base Tool functionality
10
+ * Represents a validated and ready-to-execute tool call.
11
+ * An instance of this is created by a `ToolBuilder`.
10
12
  */
11
- export interface Tool<TParams = unknown, TResult extends ToolResult = ToolResult> {
13
+ export interface ToolInvocation<TParams extends object, TResult extends ToolResult> {
12
14
  /**
13
- * The internal name of the tool (used for API calls)
15
+ * The validated parameters for this specific invocation.
14
16
  */
15
- name: string;
17
+ params: TParams;
16
18
  /**
17
- * The user-friendly display name of the tool
19
+ * Gets a pre-execution description of the tool operation.
20
+ * @returns A markdown string describing what the tool will do.
18
21
  */
19
- displayName: string;
22
+ getDescription(): string;
20
23
  /**
21
- * Description of what the tool does
24
+ * Determines what file system paths the tool will affect.
25
+ * @returns A list of such paths.
22
26
  */
23
- description: string;
27
+ toolLocations(): ToolLocation[];
24
28
  /**
25
- * The icon to display when interacting via ACP
29
+ * Determines if the tool should prompt for confirmation before execution.
30
+ * @returns Confirmation details or false if no confirmation is needed.
26
31
  */
27
- icon: Icon;
32
+ shouldConfirmExecute(abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
28
33
  /**
29
- * Function declaration schema from @google/genai
34
+ * Executes the tool with the validated parameters.
35
+ * @param signal AbortSignal for tool cancellation.
36
+ * @param updateOutput Optional callback to stream output.
37
+ * @returns Result of the tool execution.
30
38
  */
31
- schema: FunctionDeclaration;
39
+ execute(signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
40
+ }
41
+ /**
42
+ * A convenience base class for ToolInvocation.
43
+ */
44
+ export declare abstract class BaseToolInvocation<TParams extends object, TResult extends ToolResult> implements ToolInvocation<TParams, TResult> {
45
+ readonly params: TParams;
46
+ constructor(params: TParams);
47
+ abstract getDescription(): string;
48
+ toolLocations(): ToolLocation[];
49
+ shouldConfirmExecute(_abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
50
+ abstract execute(signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
51
+ }
52
+ /**
53
+ * A type alias for a tool invocation where the specific parameter and result types are not known.
54
+ */
55
+ export type AnyToolInvocation = ToolInvocation<object, ToolResult>;
56
+ /**
57
+ * Interface for a tool builder that validates parameters and creates invocations.
58
+ */
59
+ export interface ToolBuilder<TParams extends object, TResult extends ToolResult> {
32
60
  /**
33
- * Whether the tool's output should be rendered as markdown
61
+ * The internal name of the tool (used for API calls).
34
62
  */
35
- isOutputMarkdown: boolean;
63
+ name: string;
36
64
  /**
37
- * Whether the tool supports live (streaming) output
65
+ * The user-friendly display name of the tool.
38
66
  */
39
- canUpdateOutput: boolean;
67
+ displayName: string;
40
68
  /**
41
- * Validates the parameters for the tool
42
- * Should be called from both `shouldConfirmExecute` and `execute`
43
- * `shouldConfirmExecute` should return false immediately if invalid
44
- * @param params Parameters to validate
45
- * @returns An error message string if invalid, null otherwise
69
+ * Description of what the tool does.
46
70
  */
47
- validateToolParams(params: TParams): string | null;
71
+ description: string;
48
72
  /**
49
- * Gets a pre-execution description of the tool operation
50
- * @param params Parameters for the tool execution
51
- * @returns A markdown string describing what the tool will do
52
- * Optional for backward compatibility
73
+ * The kind of tool for categorization and permissions
53
74
  */
54
- getDescription(params: TParams): string;
75
+ kind: Kind;
55
76
  /**
56
- * Determines what file system paths the tool will affect
57
- * @param params Parameters for the tool execution
58
- * @returns A list of such paths
77
+ * Function declaration schema from @google/genai.
59
78
  */
60
- toolLocations(params: TParams): ToolLocation[];
79
+ schema: FunctionDeclaration;
61
80
  /**
62
- * Determines if the tool should prompt for confirmation before execution
63
- * @param params Parameters for the tool execution
64
- * @returns Whether execute should be confirmed.
81
+ * Whether the tool's output should be rendered as markdown.
65
82
  */
66
- shouldConfirmExecute(params: TParams, abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
83
+ isOutputMarkdown: boolean;
67
84
  /**
68
- * Executes the tool with the given parameters
69
- * @param params Parameters for the tool execution
70
- * @returns Result of the tool execution
85
+ * Whether the tool supports live (streaming) output.
71
86
  */
72
- execute(params: TParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
87
+ canUpdateOutput: boolean;
88
+ /**
89
+ * Validates raw parameters and builds a ready-to-execute invocation.
90
+ * @param params The raw, untrusted parameters from the model.
91
+ * @returns A valid `ToolInvocation` if successful. Throws an error if validation fails.
92
+ */
93
+ build(params: TParams): ToolInvocation<TParams, TResult>;
73
94
  }
74
95
  /**
75
- * Base implementation for tools with common functionality
96
+ * New base class for tools that separates validation from execution.
97
+ * New tools should extend this class.
76
98
  */
77
- export declare abstract class BaseTool<TParams = unknown, TResult extends ToolResult = ToolResult> implements Tool<TParams, TResult> {
99
+ export declare abstract class DeclarativeTool<TParams extends object, TResult extends ToolResult> implements ToolBuilder<TParams, TResult> {
78
100
  readonly name: string;
79
101
  readonly displayName: string;
80
102
  readonly description: string;
81
- readonly icon: Icon;
82
- readonly parameterSchema: Schema;
103
+ readonly kind: Kind;
104
+ readonly parameterSchema: unknown;
83
105
  readonly isOutputMarkdown: boolean;
84
106
  readonly canUpdateOutput: boolean;
85
- /**
86
- * Creates a new instance of BaseTool
87
- * @param name Internal name of the tool (used for API calls)
88
- * @param displayName User-friendly display name of the tool
89
- * @param description Description of what the tool does
90
- * @param isOutputMarkdown Whether the tool's output should be rendered as markdown
91
- * @param canUpdateOutput Whether the tool supports live (streaming) output
92
- * @param parameterSchema Open API 3.0 Schema defining the parameters
93
- */
94
- constructor(name: string, displayName: string, description: string, icon: Icon, parameterSchema: Schema, isOutputMarkdown?: boolean, canUpdateOutput?: boolean);
95
- /**
96
- * Function declaration schema computed from name, description, and parameterSchema
97
- */
107
+ constructor(name: string, displayName: string, description: string, kind: Kind, parameterSchema: unknown, isOutputMarkdown?: boolean, canUpdateOutput?: boolean);
98
108
  get schema(): FunctionDeclaration;
99
109
  /**
100
- * Validates the parameters for the tool
101
- * This is a placeholder implementation and should be overridden
102
- * Should be called from both `shouldConfirmExecute` and `execute`
103
- * `shouldConfirmExecute` should return false immediately if invalid
104
- * @param params Parameters to validate
105
- * @returns An error message string if invalid, null otherwise
110
+ * Validates the raw tool parameters.
111
+ * Subclasses should override this to add custom validation logic
112
+ * beyond the JSON schema check.
113
+ * @param params The raw parameters from the model.
114
+ * @returns An error message string if invalid, null otherwise.
106
115
  */
107
- validateToolParams(params: TParams): string | null;
116
+ validateToolParams(_params: TParams): string | null;
108
117
  /**
109
- * Gets a pre-execution description of the tool operation
110
- * Default implementation that should be overridden by derived classes
111
- * @param params Parameters for the tool execution
112
- * @returns A markdown string describing what the tool will do
118
+ * The core of the new pattern. It validates parameters and, if successful,
119
+ * returns a `ToolInvocation` object that encapsulates the logic for the
120
+ * specific, validated call.
121
+ * @param params The raw, untrusted parameters from the model.
122
+ * @returns A `ToolInvocation` instance.
113
123
  */
114
- getDescription(params: TParams): string;
124
+ abstract build(params: TParams): ToolInvocation<TParams, TResult>;
115
125
  /**
116
- * Determines if the tool should prompt for confirmation before execution
117
- * @param params Parameters for the tool execution
118
- * @returns Whether or not execute should be confirmed by the user.
126
+ * A convenience method that builds and executes the tool in one step.
127
+ * Throws an error if validation fails.
128
+ * @param params The raw, untrusted parameters from the model.
129
+ * @param signal AbortSignal for tool cancellation.
130
+ * @param updateOutput Optional callback to stream output.
131
+ * @returns The result of the tool execution.
119
132
  */
120
- shouldConfirmExecute(params: TParams, abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
133
+ buildAndExecute(params: TParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
121
134
  /**
122
- * Determines what file system paths the tool will affect
123
- * @param params Parameters for the tool execution
124
- * @returns A list of such paths
135
+ * Similar to `build` but never throws.
136
+ * @param params The raw, untrusted parameters from the model.
137
+ * @returns A `ToolInvocation` instance.
125
138
  */
126
- toolLocations(params: TParams): ToolLocation[];
139
+ private silentBuild;
127
140
  /**
128
- * Abstract method to execute the tool with the given parameters
129
- * Must be implemented by derived classes
130
- * @param params Parameters for the tool execution
131
- * @param signal AbortSignal for tool cancellation
132
- * @returns Result of the tool execution
141
+ * A convenience method that builds and executes the tool in one step.
142
+ * Never throws.
143
+ * @param params The raw, untrusted parameters from the model.
144
+ * @params abortSignal a signal to abort.
145
+ * @returns The result of the tool execution.
133
146
  */
134
- abstract execute(params: TParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
147
+ validateBuildAndExecute(params: TParams, abortSignal: AbortSignal): Promise<ToolResult>;
135
148
  }
149
+ /**
150
+ * New base class for declarative tools that separates validation from execution.
151
+ * New tools should extend this class, which provides a `build` method that
152
+ * validates parameters before deferring to a `createInvocation` method for
153
+ * the final `ToolInvocation` object instantiation.
154
+ */
155
+ export declare abstract class BaseDeclarativeTool<TParams extends object, TResult extends ToolResult> extends DeclarativeTool<TParams, TResult> {
156
+ build(params: TParams): ToolInvocation<TParams, TResult>;
157
+ validateToolParams(params: TParams): string | null;
158
+ protected validateToolParamValues(_params: TParams): string | null;
159
+ protected abstract createInvocation(params: TParams): ToolInvocation<TParams, TResult>;
160
+ }
161
+ /**
162
+ * A type alias for a declarative tool where the specific parameter and result types are not known.
163
+ */
164
+ export type AnyDeclarativeTool = DeclarativeTool<object, ToolResult>;
136
165
  export interface ToolResult {
137
166
  /**
138
167
  * A short, one-line summary of the tool's action and result.
@@ -160,22 +189,37 @@ export interface ToolResult {
160
189
  type?: ToolErrorType;
161
190
  };
162
191
  }
192
+ /**
193
+ * Detects cycles in a JSON schemas due to `$ref`s.
194
+ * @param schema The root of the JSON schema.
195
+ * @returns `true` if a cycle is detected, `false` otherwise.
196
+ */
197
+ export declare function hasCycleInSchema(schema: object): boolean;
163
198
  export type ToolResultDisplay = string | FileDiff;
164
199
  export interface FileDiff {
165
200
  fileDiff: string;
166
201
  fileName: string;
167
202
  originalContent: string | null;
168
203
  newContent: string;
204
+ diffStat?: DiffStat;
205
+ }
206
+ export interface DiffStat {
207
+ ai_removed_lines: number;
208
+ ai_added_lines: number;
209
+ user_added_lines: number;
210
+ user_removed_lines: number;
169
211
  }
170
212
  export interface ToolEditConfirmationDetails {
171
213
  type: 'edit';
172
214
  title: string;
173
215
  onConfirm: (outcome: ToolConfirmationOutcome, payload?: ToolConfirmationPayload) => Promise<void>;
174
216
  fileName: string;
217
+ filePath: string;
175
218
  fileDiff: string;
176
219
  originalContent: string | null;
177
220
  newContent: string;
178
221
  isModifying?: boolean;
222
+ ideConfirmation?: Promise<DiffUpdateResult>;
179
223
  }
180
224
  export interface ToolConfirmationPayload {
181
225
  newContent: string;
@@ -211,15 +255,16 @@ export declare enum ToolConfirmationOutcome {
211
255
  ModifyWithEditor = "modify_with_editor",
212
256
  Cancel = "cancel"
213
257
  }
214
- export declare enum Icon {
215
- FileSearch = "fileSearch",
216
- Folder = "folder",
217
- Globe = "globe",
218
- Hammer = "hammer",
219
- LightBulb = "lightBulb",
220
- Pencil = "pencil",
221
- Regex = "regex",
222
- Terminal = "terminal"
258
+ export declare enum Kind {
259
+ Read = "read",
260
+ Edit = "edit",
261
+ Delete = "delete",
262
+ Move = "move",
263
+ Search = "search",
264
+ Execute = "execute",
265
+ Think = "think",
266
+ Fetch = "fetch",
267
+ Other = "other"
223
268
  }
224
269
  export interface ToolLocation {
225
270
  path: string;
@@ -3,90 +3,216 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { ToolErrorType } from './tool-error.js';
7
+ import { SchemaValidator } from '../utils/schemaValidator.js';
6
8
  /**
7
- * Base implementation for tools with common functionality
9
+ * A convenience base class for ToolInvocation.
8
10
  */
9
- export class BaseTool {
11
+ export class BaseToolInvocation {
12
+ params;
13
+ constructor(params) {
14
+ this.params = params;
15
+ }
16
+ toolLocations() {
17
+ return [];
18
+ }
19
+ shouldConfirmExecute(_abortSignal) {
20
+ return Promise.resolve(false);
21
+ }
22
+ }
23
+ /**
24
+ * New base class for tools that separates validation from execution.
25
+ * New tools should extend this class.
26
+ */
27
+ export class DeclarativeTool {
10
28
  name;
11
29
  displayName;
12
30
  description;
13
- icon;
31
+ kind;
14
32
  parameterSchema;
15
33
  isOutputMarkdown;
16
34
  canUpdateOutput;
17
- /**
18
- * Creates a new instance of BaseTool
19
- * @param name Internal name of the tool (used for API calls)
20
- * @param displayName User-friendly display name of the tool
21
- * @param description Description of what the tool does
22
- * @param isOutputMarkdown Whether the tool's output should be rendered as markdown
23
- * @param canUpdateOutput Whether the tool supports live (streaming) output
24
- * @param parameterSchema Open API 3.0 Schema defining the parameters
25
- */
26
- constructor(name, displayName, description, icon, parameterSchema, isOutputMarkdown = true, canUpdateOutput = false) {
35
+ constructor(name, displayName, description, kind, parameterSchema, isOutputMarkdown = true, canUpdateOutput = false) {
27
36
  this.name = name;
28
37
  this.displayName = displayName;
29
38
  this.description = description;
30
- this.icon = icon;
39
+ this.kind = kind;
31
40
  this.parameterSchema = parameterSchema;
32
41
  this.isOutputMarkdown = isOutputMarkdown;
33
42
  this.canUpdateOutput = canUpdateOutput;
34
43
  }
35
- /**
36
- * Function declaration schema computed from name, description, and parameterSchema
37
- */
38
44
  get schema() {
39
45
  return {
40
46
  name: this.name,
41
47
  description: this.description,
42
- parameters: this.parameterSchema,
48
+ parametersJsonSchema: this.parameterSchema,
43
49
  };
44
50
  }
45
51
  /**
46
- * Validates the parameters for the tool
47
- * This is a placeholder implementation and should be overridden
48
- * Should be called from both `shouldConfirmExecute` and `execute`
49
- * `shouldConfirmExecute` should return false immediately if invalid
50
- * @param params Parameters to validate
51
- * @returns An error message string if invalid, null otherwise
52
+ * Validates the raw tool parameters.
53
+ * Subclasses should override this to add custom validation logic
54
+ * beyond the JSON schema check.
55
+ * @param params The raw parameters from the model.
56
+ * @returns An error message string if invalid, null otherwise.
52
57
  */
53
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
54
- validateToolParams(params) {
55
- // Implementation would typically use a JSON Schema validator
56
- // This is a placeholder that should be implemented by derived classes
58
+ validateToolParams(_params) {
59
+ // Base implementation can be extended by subclasses.
57
60
  return null;
58
61
  }
59
62
  /**
60
- * Gets a pre-execution description of the tool operation
61
- * Default implementation that should be overridden by derived classes
62
- * @param params Parameters for the tool execution
63
- * @returns A markdown string describing what the tool will do
63
+ * A convenience method that builds and executes the tool in one step.
64
+ * Throws an error if validation fails.
65
+ * @param params The raw, untrusted parameters from the model.
66
+ * @param signal AbortSignal for tool cancellation.
67
+ * @param updateOutput Optional callback to stream output.
68
+ * @returns The result of the tool execution.
64
69
  */
65
- getDescription(params) {
66
- return JSON.stringify(params);
70
+ async buildAndExecute(params, signal, updateOutput) {
71
+ const invocation = this.build(params);
72
+ return invocation.execute(signal, updateOutput);
67
73
  }
68
74
  /**
69
- * Determines if the tool should prompt for confirmation before execution
70
- * @param params Parameters for the tool execution
71
- * @returns Whether or not execute should be confirmed by the user.
75
+ * Similar to `build` but never throws.
76
+ * @param params The raw, untrusted parameters from the model.
77
+ * @returns A `ToolInvocation` instance.
72
78
  */
73
- shouldConfirmExecute(
74
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
75
- params,
76
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
77
- abortSignal) {
78
- return Promise.resolve(false);
79
+ silentBuild(params) {
80
+ try {
81
+ return this.build(params);
82
+ }
83
+ catch (e) {
84
+ if (e instanceof Error) {
85
+ return e;
86
+ }
87
+ return new Error(String(e));
88
+ }
79
89
  }
80
90
  /**
81
- * Determines what file system paths the tool will affect
82
- * @param params Parameters for the tool execution
83
- * @returns A list of such paths
91
+ * A convenience method that builds and executes the tool in one step.
92
+ * Never throws.
93
+ * @param params The raw, untrusted parameters from the model.
94
+ * @params abortSignal a signal to abort.
95
+ * @returns The result of the tool execution.
84
96
  */
85
- toolLocations(
86
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
87
- params) {
88
- return [];
97
+ async validateBuildAndExecute(params, abortSignal) {
98
+ const invocationOrError = this.silentBuild(params);
99
+ if (invocationOrError instanceof Error) {
100
+ const errorMessage = invocationOrError.message;
101
+ return {
102
+ llmContent: `Error: Invalid parameters provided. Reason: ${errorMessage}`,
103
+ returnDisplay: errorMessage,
104
+ error: {
105
+ message: errorMessage,
106
+ type: ToolErrorType.INVALID_TOOL_PARAMS,
107
+ },
108
+ };
109
+ }
110
+ try {
111
+ return await invocationOrError.execute(abortSignal);
112
+ }
113
+ catch (error) {
114
+ const errorMessage = error instanceof Error ? error.message : String(error);
115
+ return {
116
+ llmContent: `Error: Tool call execution failed. Reason: ${errorMessage}`,
117
+ returnDisplay: errorMessage,
118
+ error: {
119
+ message: errorMessage,
120
+ type: ToolErrorType.EXECUTION_FAILED,
121
+ },
122
+ };
123
+ }
124
+ }
125
+ }
126
+ /**
127
+ * New base class for declarative tools that separates validation from execution.
128
+ * New tools should extend this class, which provides a `build` method that
129
+ * validates parameters before deferring to a `createInvocation` method for
130
+ * the final `ToolInvocation` object instantiation.
131
+ */
132
+ export class BaseDeclarativeTool extends DeclarativeTool {
133
+ build(params) {
134
+ const validationError = this.validateToolParams(params);
135
+ if (validationError) {
136
+ throw new Error(validationError);
137
+ }
138
+ return this.createInvocation(params);
139
+ }
140
+ validateToolParams(params) {
141
+ const errors = SchemaValidator.validate(this.schema.parametersJsonSchema, params);
142
+ if (errors) {
143
+ return errors;
144
+ }
145
+ return this.validateToolParamValues(params);
146
+ }
147
+ validateToolParamValues(_params) {
148
+ // Base implementation can be extended by subclasses.
149
+ return null;
150
+ }
151
+ }
152
+ /**
153
+ * Detects cycles in a JSON schemas due to `$ref`s.
154
+ * @param schema The root of the JSON schema.
155
+ * @returns `true` if a cycle is detected, `false` otherwise.
156
+ */
157
+ export function hasCycleInSchema(schema) {
158
+ function resolveRef(ref) {
159
+ if (!ref.startsWith('#/')) {
160
+ return null;
161
+ }
162
+ const path = ref.substring(2).split('/');
163
+ let current = schema;
164
+ for (const segment of path) {
165
+ if (typeof current !== 'object' ||
166
+ current === null ||
167
+ !Object.prototype.hasOwnProperty.call(current, segment)) {
168
+ return null;
169
+ }
170
+ current = current[segment];
171
+ }
172
+ return current;
173
+ }
174
+ function traverse(node, visitedRefs, pathRefs) {
175
+ if (typeof node !== 'object' || node === null) {
176
+ return false;
177
+ }
178
+ if (Array.isArray(node)) {
179
+ for (const item of node) {
180
+ if (traverse(item, visitedRefs, pathRefs)) {
181
+ return true;
182
+ }
183
+ }
184
+ return false;
185
+ }
186
+ if ('$ref' in node && typeof node.$ref === 'string') {
187
+ const ref = node.$ref;
188
+ if (ref === '#/' || pathRefs.has(ref)) {
189
+ // A ref to just '#/' is always a cycle.
190
+ return true; // Cycle detected!
191
+ }
192
+ if (visitedRefs.has(ref)) {
193
+ return false; // Bail early, we have checked this ref before.
194
+ }
195
+ const resolvedNode = resolveRef(ref);
196
+ if (resolvedNode) {
197
+ // Add it to both visited and the current path
198
+ visitedRefs.add(ref);
199
+ pathRefs.add(ref);
200
+ const hasCycle = traverse(resolvedNode, visitedRefs, pathRefs);
201
+ pathRefs.delete(ref); // Backtrack, leaving it in visited
202
+ return hasCycle;
203
+ }
204
+ }
205
+ // Crawl all the properties of node
206
+ for (const key in node) {
207
+ if (Object.prototype.hasOwnProperty.call(node, key)) {
208
+ if (traverse(node[key], visitedRefs, pathRefs)) {
209
+ return true;
210
+ }
211
+ }
212
+ }
213
+ return false;
89
214
  }
215
+ return traverse(schema, new Set(), new Set());
90
216
  }
91
217
  export var ToolConfirmationOutcome;
92
218
  (function (ToolConfirmationOutcome) {
@@ -97,15 +223,16 @@ export var ToolConfirmationOutcome;
97
223
  ToolConfirmationOutcome["ModifyWithEditor"] = "modify_with_editor";
98
224
  ToolConfirmationOutcome["Cancel"] = "cancel";
99
225
  })(ToolConfirmationOutcome || (ToolConfirmationOutcome = {}));
100
- export var Icon;
101
- (function (Icon) {
102
- Icon["FileSearch"] = "fileSearch";
103
- Icon["Folder"] = "folder";
104
- Icon["Globe"] = "globe";
105
- Icon["Hammer"] = "hammer";
106
- Icon["LightBulb"] = "lightBulb";
107
- Icon["Pencil"] = "pencil";
108
- Icon["Regex"] = "regex";
109
- Icon["Terminal"] = "terminal";
110
- })(Icon || (Icon = {}));
226
+ export var Kind;
227
+ (function (Kind) {
228
+ Kind["Read"] = "read";
229
+ Kind["Edit"] = "edit";
230
+ Kind["Delete"] = "delete";
231
+ Kind["Move"] = "move";
232
+ Kind["Search"] = "search";
233
+ Kind["Execute"] = "execute";
234
+ Kind["Think"] = "think";
235
+ Kind["Fetch"] = "fetch";
236
+ Kind["Other"] = "other";
237
+ })(Kind || (Kind = {}));
111
238
  //# sourceMappingURL=tools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/tools/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6FH;;GAEG;AACH,MAAM,OAAgB,QAAQ;IAejB;IACA;IACA;IACA;IACA;IACA;IACA;IAhBX;;;;;;;;OAQG;IACH,YACW,IAAY,EACZ,WAAmB,EACnB,WAAmB,EACnB,IAAU,EACV,eAAuB,EACvB,mBAA4B,IAAI,EAChC,kBAA2B,KAAK;QANhC,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,SAAI,GAAJ,IAAI,CAAM;QACV,oBAAe,GAAf,eAAe,CAAQ;QACvB,qBAAgB,GAAhB,gBAAgB,CAAgB;QAChC,oBAAe,GAAf,eAAe,CAAiB;IACxC,CAA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