@office-ai/aioncli-core 0.8.1 → 0.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (777) 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.js +31 -8
  165. package/dist/src/core/openaiContentGenerator.js.map +1 -1
  166. package/dist/src/core/prompts.d.ts +2 -1
  167. package/dist/src/core/prompts.js +135 -154
  168. package/dist/src/core/prompts.js.map +1 -1
  169. package/dist/src/core/prompts.test.js +128 -189
  170. package/dist/src/core/prompts.test.js.map +1 -1
  171. package/dist/src/core/recordingContentGenerator.d.ts +18 -0
  172. package/dist/src/core/recordingContentGenerator.js +77 -0
  173. package/dist/src/core/recordingContentGenerator.js.map +1 -0
  174. package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
  175. package/dist/src/core/recordingContentGenerator.test.js +101 -0
  176. package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
  177. package/dist/src/core/tokenLimits.test.d.ts +6 -0
  178. package/dist/src/core/tokenLimits.test.js +26 -0
  179. package/dist/src/core/tokenLimits.test.js.map +1 -0
  180. package/dist/src/core/turn.d.ts +23 -3
  181. package/dist/src/core/turn.js +18 -9
  182. package/dist/src/core/turn.js.map +1 -1
  183. package/dist/src/core/turn.test.js +98 -104
  184. package/dist/src/core/turn.test.js.map +1 -1
  185. package/dist/src/fallback/handler.js +60 -8
  186. package/dist/src/fallback/handler.js.map +1 -1
  187. package/dist/src/fallback/handler.test.js +132 -17
  188. package/dist/src/fallback/handler.test.js.map +1 -1
  189. package/dist/src/fallback/types.d.ts +1 -1
  190. package/dist/src/generated/git-commit.d.ts +2 -2
  191. package/dist/src/generated/git-commit.js +2 -2
  192. package/dist/src/generated/git-commit.js.map +1 -1
  193. package/dist/src/hooks/hookAggregator.d.ts +68 -0
  194. package/dist/src/hooks/hookAggregator.js +262 -0
  195. package/dist/src/hooks/hookAggregator.js.map +1 -0
  196. package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
  197. package/dist/src/hooks/hookAggregator.test.js +387 -0
  198. package/dist/src/hooks/hookAggregator.test.js.map +1 -0
  199. package/dist/src/hooks/hookPlanner.d.ts +46 -0
  200. package/dist/src/hooks/hookPlanner.js +108 -0
  201. package/dist/src/hooks/hookPlanner.js.map +1 -0
  202. package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
  203. package/dist/src/hooks/hookPlanner.test.js +255 -0
  204. package/dist/src/hooks/hookPlanner.test.js.map +1 -0
  205. package/dist/src/hooks/hookRegistry.d.ts +87 -0
  206. package/dist/src/hooks/hookRegistry.js +198 -0
  207. package/dist/src/hooks/hookRegistry.js.map +1 -0
  208. package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
  209. package/dist/src/hooks/hookRegistry.test.js +341 -0
  210. package/dist/src/hooks/hookRegistry.test.js.map +1 -0
  211. package/dist/src/hooks/hookRunner.d.ts +42 -0
  212. package/dist/src/hooks/hookRunner.js +272 -0
  213. package/dist/src/hooks/hookRunner.js.map +1 -0
  214. package/dist/src/hooks/hookRunner.test.d.ts +6 -0
  215. package/dist/src/hooks/hookRunner.test.js +468 -0
  216. package/dist/src/hooks/hookRunner.test.js.map +1 -0
  217. package/dist/src/hooks/hookTranslator.d.ts +113 -0
  218. package/dist/src/hooks/hookTranslator.js +232 -0
  219. package/dist/src/hooks/hookTranslator.js.map +1 -0
  220. package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
  221. package/dist/src/hooks/hookTranslator.test.js +192 -0
  222. package/dist/src/hooks/hookTranslator.test.js.map +1 -0
  223. package/dist/src/hooks/types.d.ts +384 -0
  224. package/dist/src/hooks/types.js +284 -0
  225. package/dist/src/hooks/types.js.map +1 -0
  226. package/dist/src/hooks/types.test.d.ts +6 -0
  227. package/dist/src/hooks/types.test.js +313 -0
  228. package/dist/src/hooks/types.test.js.map +1 -0
  229. package/dist/src/ide/detect-ide.d.ts +4 -0
  230. package/dist/src/ide/detect-ide.js +6 -1
  231. package/dist/src/ide/detect-ide.js.map +1 -1
  232. package/dist/src/ide/detect-ide.test.js +16 -0
  233. package/dist/src/ide/detect-ide.test.js.map +1 -1
  234. package/dist/src/ide/ide-client.d.ts +3 -1
  235. package/dist/src/ide/ide-client.js +12 -10
  236. package/dist/src/ide/ide-client.js.map +1 -1
  237. package/dist/src/ide/ide-client.test.js +163 -4
  238. package/dist/src/ide/ide-client.test.js.map +1 -1
  239. package/dist/src/ide/ide-installer.js +66 -21
  240. package/dist/src/ide/ide-installer.js.map +1 -1
  241. package/dist/src/ide/ide-installer.test.js +54 -1
  242. package/dist/src/ide/ide-installer.test.js.map +1 -1
  243. package/dist/src/ide/process-utils.js +85 -75
  244. package/dist/src/ide/process-utils.js.map +1 -1
  245. package/dist/src/ide/process-utils.test.js +83 -90
  246. package/dist/src/ide/process-utils.test.js.map +1 -1
  247. package/dist/src/ide/types.d.ts +1 -1
  248. package/dist/src/ide/types.js +1 -1
  249. package/dist/src/index.d.ts +21 -0
  250. package/dist/src/index.js +24 -0
  251. package/dist/src/index.js.map +1 -1
  252. package/dist/src/mcp/google-auth-provider.d.ts +2 -0
  253. package/dist/src/mcp/google-auth-provider.js +21 -3
  254. package/dist/src/mcp/google-auth-provider.js.map +1 -1
  255. package/dist/src/mcp/google-auth-provider.test.js +42 -9
  256. package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
  257. package/dist/src/mcp/oauth-provider.d.ts +8 -5
  258. package/dist/src/mcp/oauth-provider.js +140 -55
  259. package/dist/src/mcp/oauth-provider.js.map +1 -1
  260. package/dist/src/mcp/oauth-provider.test.js +369 -2
  261. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  262. package/dist/src/mcp/oauth-token-storage.js +5 -4
  263. package/dist/src/mcp/oauth-token-storage.js.map +1 -1
  264. package/dist/src/mcp/oauth-token-storage.test.js +17 -11
  265. package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
  266. package/dist/src/mcp/oauth-utils.d.ts +7 -0
  267. package/dist/src/mcp/oauth-utils.js +28 -8
  268. package/dist/src/mcp/oauth-utils.js.map +1 -1
  269. package/dist/src/mcp/oauth-utils.test.js +45 -2
  270. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  271. package/dist/src/mcp/sa-impersonation-provider.d.ts +0 -6
  272. package/dist/src/mcp/sa-impersonation-provider.js +6 -23
  273. package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
  274. package/dist/src/mcp/token-storage/base-token-storage.test.js +75 -84
  275. package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -1
  276. package/dist/src/mcp/token-storage/file-token-storage.js +3 -2
  277. package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
  278. package/dist/src/mcp/token-storage/file-token-storage.test.js +11 -8
  279. package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
  280. package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +6 -2
  281. package/dist/src/mcp/token-storage/keychain-token-storage.js +63 -7
  282. package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
  283. package/dist/src/mcp/token-storage/keychain-token-storage.test.js +54 -3
  284. package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -1
  285. package/dist/src/mcp/token-storage/types.d.ts +6 -0
  286. package/dist/src/mcp/token-storage/types.js.map +1 -1
  287. package/dist/src/output/stream-json-formatter.d.ts +32 -0
  288. package/dist/src/output/stream-json-formatter.js +52 -0
  289. package/dist/src/output/stream-json-formatter.js.map +1 -0
  290. package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
  291. package/dist/src/output/stream-json-formatter.test.js +479 -0
  292. package/dist/src/output/stream-json-formatter.test.js.map +1 -0
  293. package/dist/src/output/types.d.ts +63 -1
  294. package/dist/src/output/types.js +11 -0
  295. package/dist/src/output/types.js.map +1 -1
  296. package/dist/src/policy/config.d.ts +31 -0
  297. package/dist/src/policy/config.js +199 -0
  298. package/dist/src/policy/config.js.map +1 -0
  299. package/dist/src/policy/config.test.d.ts +6 -0
  300. package/dist/src/policy/config.test.js +538 -0
  301. package/dist/src/policy/config.test.js.map +1 -0
  302. package/dist/src/policy/index.d.ts +2 -0
  303. package/dist/src/policy/index.js +2 -0
  304. package/dist/src/policy/index.js.map +1 -1
  305. package/dist/src/policy/policies/discovered.toml +8 -0
  306. package/dist/src/policy/policies/read-only.toml +56 -0
  307. package/dist/src/policy/policies/write.toml +73 -0
  308. package/dist/src/policy/policies/yolo.toml +31 -0
  309. package/dist/src/policy/policy-engine.d.ts +12 -3
  310. package/dist/src/policy/policy-engine.js +74 -8
  311. package/dist/src/policy/policy-engine.js.map +1 -1
  312. package/dist/src/policy/policy-engine.test.js +460 -76
  313. package/dist/src/policy/policy-engine.test.js.map +1 -1
  314. package/dist/src/policy/toml-loader.d.ts +47 -0
  315. package/dist/src/policy/toml-loader.js +411 -0
  316. package/dist/src/policy/toml-loader.js.map +1 -0
  317. package/dist/src/policy/toml-loader.test.d.ts +6 -0
  318. package/dist/src/policy/toml-loader.test.js +376 -0
  319. package/dist/src/policy/toml-loader.test.js.map +1 -0
  320. package/dist/src/policy/types.d.ts +83 -0
  321. package/dist/src/policy/types.js +10 -0
  322. package/dist/src/policy/types.js.map +1 -1
  323. package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
  324. package/dist/src/prompts/mcp-prompts.test.js +39 -0
  325. package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
  326. package/dist/src/prompts/prompt-registry.js +2 -1
  327. package/dist/src/prompts/prompt-registry.js.map +1 -1
  328. package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
  329. package/dist/src/prompts/prompt-registry.test.js +96 -0
  330. package/dist/src/prompts/prompt-registry.test.js.map +1 -0
  331. package/dist/src/routing/modelRouterService.js +15 -0
  332. package/dist/src/routing/modelRouterService.js.map +1 -1
  333. package/dist/src/routing/modelRouterService.test.js +62 -0
  334. package/dist/src/routing/modelRouterService.test.js.map +1 -1
  335. package/dist/src/routing/strategies/classifierStrategy.d.ts +1 -1
  336. package/dist/src/routing/strategies/classifierStrategy.js +9 -16
  337. package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
  338. package/dist/src/routing/strategies/classifierStrategy.test.js +17 -13
  339. package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
  340. package/dist/src/routing/strategies/fallbackStrategy.js +1 -1
  341. package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
  342. package/dist/src/routing/strategies/fallbackStrategy.test.js +4 -0
  343. package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
  344. package/dist/src/routing/strategies/overrideStrategy.js +2 -2
  345. package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
  346. package/dist/src/routing/strategies/overrideStrategy.test.js +3 -0
  347. package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
  348. package/dist/src/safety/built-in.d.ts +21 -0
  349. package/dist/src/safety/built-in.js +106 -0
  350. package/dist/src/safety/built-in.js.map +1 -0
  351. package/dist/src/safety/built-in.test.d.ts +6 -0
  352. package/dist/src/safety/built-in.test.js +199 -0
  353. package/dist/src/safety/built-in.test.js.map +1 -0
  354. package/dist/src/safety/checker-runner.d.ts +48 -0
  355. package/dist/src/safety/checker-runner.js +208 -0
  356. package/dist/src/safety/checker-runner.js.map +1 -0
  357. package/dist/src/safety/checker-runner.test.d.ts +6 -0
  358. package/dist/src/safety/checker-runner.test.js +238 -0
  359. package/dist/src/safety/checker-runner.test.js.map +1 -0
  360. package/dist/src/safety/context-builder.d.ts +23 -0
  361. package/dist/src/safety/context-builder.js +47 -0
  362. package/dist/src/safety/context-builder.js.map +1 -0
  363. package/dist/src/safety/context-builder.test.d.ts +6 -0
  364. package/dist/src/safety/context-builder.test.js +49 -0
  365. package/dist/src/safety/context-builder.test.js.map +1 -0
  366. package/dist/src/safety/protocol.d.ts +88 -0
  367. package/dist/src/safety/protocol.js +15 -0
  368. package/dist/src/safety/protocol.js.map +1 -0
  369. package/dist/src/safety/registry.d.ts +26 -0
  370. package/dist/src/safety/registry.js +65 -0
  371. package/dist/src/safety/registry.js.map +1 -0
  372. package/dist/src/safety/registry.test.d.ts +6 -0
  373. package/dist/src/safety/registry.test.js +31 -0
  374. package/dist/src/safety/registry.test.js.map +1 -0
  375. package/dist/src/services/chatCompressionService.d.ts +32 -0
  376. package/dist/src/services/chatCompressionService.js +162 -0
  377. package/dist/src/services/chatCompressionService.js.map +1 -0
  378. package/dist/src/services/chatCompressionService.test.d.ts +6 -0
  379. package/dist/src/services/chatCompressionService.test.js +210 -0
  380. package/dist/src/services/chatCompressionService.test.js.map +1 -0
  381. package/dist/src/services/chatRecordingService.d.ts +3 -2
  382. package/dist/src/services/chatRecordingService.js +11 -9
  383. package/dist/src/services/chatRecordingService.js.map +1 -1
  384. package/dist/src/services/fileDiscoveryService.d.ts +2 -14
  385. package/dist/src/services/fileDiscoveryService.js +19 -55
  386. package/dist/src/services/fileDiscoveryService.js.map +1 -1
  387. package/dist/src/services/fileDiscoveryService.test.js +91 -11
  388. package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
  389. package/dist/src/services/loopDetectionService.d.ts +4 -1
  390. package/dist/src/services/loopDetectionService.js +95 -42
  391. package/dist/src/services/loopDetectionService.js.map +1 -1
  392. package/dist/src/services/loopDetectionService.test.js +220 -12
  393. package/dist/src/services/loopDetectionService.test.js.map +1 -1
  394. package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
  395. package/dist/src/services/modelConfig.golden.test.js +42 -0
  396. package/dist/src/services/modelConfig.golden.test.js.map +1 -0
  397. package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
  398. package/dist/src/services/modelConfig.integration.test.js +247 -0
  399. package/dist/src/services/modelConfig.integration.test.js.map +1 -0
  400. package/dist/src/services/modelConfigService.d.ts +48 -0
  401. package/dist/src/services/modelConfigService.js +151 -0
  402. package/dist/src/services/modelConfigService.js.map +1 -0
  403. package/dist/src/services/modelConfigService.test.d.ts +6 -0
  404. package/dist/src/services/modelConfigService.test.js +531 -0
  405. package/dist/src/services/modelConfigService.test.js.map +1 -0
  406. package/dist/src/services/shellExecutionService.d.ts +1 -0
  407. package/dist/src/services/shellExecutionService.js +195 -92
  408. package/dist/src/services/shellExecutionService.js.map +1 -1
  409. package/dist/src/services/shellExecutionService.test.js +137 -14
  410. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  411. package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
  412. package/dist/src/telemetry/activity-monitor.d.ts +116 -0
  413. package/dist/src/telemetry/activity-monitor.js +209 -0
  414. package/dist/src/telemetry/activity-monitor.js.map +1 -0
  415. package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
  416. package/dist/src/telemetry/activity-monitor.test.js +251 -0
  417. package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
  418. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +25 -7
  419. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +294 -76
  420. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  421. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
  422. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +192 -66
  423. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  424. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +25 -3
  425. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +59 -5
  426. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  427. package/dist/src/telemetry/constants.d.ts +0 -28
  428. package/dist/src/telemetry/constants.js +0 -29
  429. package/dist/src/telemetry/constants.js.map +1 -1
  430. package/dist/src/telemetry/gcp-exporters.js +0 -1
  431. package/dist/src/telemetry/gcp-exporters.js.map +1 -1
  432. package/dist/src/telemetry/gcp-exporters.test.js +1 -1
  433. package/dist/src/telemetry/gcp-exporters.test.js.map +1 -1
  434. package/dist/src/telemetry/index.d.ts +7 -3
  435. package/dist/src/telemetry/index.js +13 -4
  436. package/dist/src/telemetry/index.js.map +1 -1
  437. package/dist/src/telemetry/loggers.d.ts +14 -7
  438. package/dist/src/telemetry/loggers.js +197 -320
  439. package/dist/src/telemetry/loggers.js.map +1 -1
  440. package/dist/src/telemetry/loggers.test.circular.js +0 -1
  441. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  442. package/dist/src/telemetry/loggers.test.js +460 -59
  443. package/dist/src/telemetry/loggers.test.js.map +1 -1
  444. package/dist/src/telemetry/memory-monitor.d.ts +149 -0
  445. package/dist/src/telemetry/memory-monitor.js +335 -0
  446. package/dist/src/telemetry/memory-monitor.js.map +1 -0
  447. package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
  448. package/dist/src/telemetry/memory-monitor.test.js +472 -0
  449. package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
  450. package/dist/src/telemetry/metrics.d.ts +180 -4
  451. package/dist/src/telemetry/metrics.js +270 -6
  452. package/dist/src/telemetry/metrics.js.map +1 -1
  453. package/dist/src/telemetry/metrics.test.js +502 -184
  454. package/dist/src/telemetry/metrics.test.js.map +1 -1
  455. package/dist/src/telemetry/sdk.js +3 -2
  456. package/dist/src/telemetry/sdk.js.map +1 -1
  457. package/dist/src/telemetry/semantic.d.ts +82 -0
  458. package/dist/src/telemetry/semantic.js +269 -0
  459. package/dist/src/telemetry/semantic.js.map +1 -0
  460. package/dist/src/telemetry/semantic.test.d.ts +6 -0
  461. package/dist/src/telemetry/semantic.test.js +387 -0
  462. package/dist/src/telemetry/semantic.test.js.map +1 -0
  463. package/dist/src/telemetry/telemetry-utils.test.js +29 -28
  464. package/dist/src/telemetry/telemetry-utils.test.js.map +1 -1
  465. package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
  466. package/dist/src/telemetry/telemetryAttributes.js +19 -0
  467. package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
  468. package/dist/src/telemetry/trace.d.ts +46 -0
  469. package/dist/src/telemetry/trace.js +121 -0
  470. package/dist/src/telemetry/trace.js.map +1 -0
  471. package/dist/src/telemetry/types.d.ts +227 -29
  472. package/dist/src/telemetry/types.js +858 -72
  473. package/dist/src/telemetry/types.js.map +1 -1
  474. package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
  475. package/dist/src/telemetry/uiTelemetry.js +7 -7
  476. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  477. package/dist/src/telemetry/uiTelemetry.test.js +89 -67
  478. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  479. package/dist/src/test-utils/config.d.ts +1 -1
  480. package/dist/src/test-utils/config.js +1 -1
  481. package/dist/src/tools/base-tool-invocation.test.d.ts +6 -0
  482. package/dist/src/tools/base-tool-invocation.test.js +85 -0
  483. package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
  484. package/dist/src/tools/edit.d.ts +4 -3
  485. package/dist/src/tools/edit.js +50 -47
  486. package/dist/src/tools/edit.js.map +1 -1
  487. package/dist/src/tools/edit.test.js +306 -216
  488. package/dist/src/tools/edit.test.js.map +1 -1
  489. package/dist/src/tools/glob.d.ts +4 -3
  490. package/dist/src/tools/glob.js +24 -27
  491. package/dist/src/tools/glob.js.map +1 -1
  492. package/dist/src/tools/glob.test.js +212 -205
  493. package/dist/src/tools/glob.test.js.map +1 -1
  494. package/dist/src/tools/grep.d.ts +4 -3
  495. package/dist/src/tools/grep.js +31 -25
  496. package/dist/src/tools/grep.js.map +1 -1
  497. package/dist/src/tools/grep.test.js +15 -12
  498. package/dist/src/tools/grep.test.js.map +1 -1
  499. package/dist/src/tools/ls.d.ts +4 -3
  500. package/dist/src/tools/ls.js +29 -35
  501. package/dist/src/tools/ls.js.map +1 -1
  502. package/dist/src/tools/ls.test.js +34 -42
  503. package/dist/src/tools/ls.test.js.map +1 -1
  504. package/dist/src/tools/mcp-client-manager.d.ts +49 -11
  505. package/dist/src/tools/mcp-client-manager.js +191 -31
  506. package/dist/src/tools/mcp-client-manager.js.map +1 -1
  507. package/dist/src/tools/mcp-client-manager.test.js +132 -25
  508. package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
  509. package/dist/src/tools/mcp-client.d.ts +12 -5
  510. package/dist/src/tools/mcp-client.js +287 -267
  511. package/dist/src/tools/mcp-client.js.map +1 -1
  512. package/dist/src/tools/mcp-client.test.js +352 -45
  513. package/dist/src/tools/mcp-client.test.js.map +1 -1
  514. package/dist/src/tools/mcp-tool.d.ts +6 -2
  515. package/dist/src/tools/mcp-tool.js +19 -8
  516. package/dist/src/tools/mcp-tool.js.map +1 -1
  517. package/dist/src/tools/mcp-tool.test.js +186 -273
  518. package/dist/src/tools/mcp-tool.test.js.map +1 -1
  519. package/dist/src/tools/memoryTool.d.ts +7 -5
  520. package/dist/src/tools/memoryTool.js +14 -12
  521. package/dist/src/tools/memoryTool.js.map +1 -1
  522. package/dist/src/tools/memoryTool.test.js +10 -9
  523. package/dist/src/tools/memoryTool.test.js.map +1 -1
  524. package/dist/src/tools/message-bus-integration.test.js +14 -1
  525. package/dist/src/tools/message-bus-integration.test.js.map +1 -1
  526. package/dist/src/tools/modifiable-tool.d.ts +5 -1
  527. package/dist/src/tools/modifiable-tool.js +38 -16
  528. package/dist/src/tools/modifiable-tool.js.map +1 -1
  529. package/dist/src/tools/modifiable-tool.test.js +66 -31
  530. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  531. package/dist/src/tools/read-file.d.ts +6 -5
  532. package/dist/src/tools/read-file.js +26 -32
  533. package/dist/src/tools/read-file.js.map +1 -1
  534. package/dist/src/tools/read-file.test.js +68 -33
  535. package/dist/src/tools/read-file.test.js.map +1 -1
  536. package/dist/src/tools/read-many-files.d.ts +6 -12
  537. package/dist/src/tools/read-many-files.js +28 -57
  538. package/dist/src/tools/read-many-files.js.map +1 -1
  539. package/dist/src/tools/read-many-files.test.js +37 -36
  540. package/dist/src/tools/read-many-files.test.js.map +1 -1
  541. package/dist/src/tools/ripGrep.d.ts +28 -10
  542. package/dist/src/tools/ripGrep.js +195 -193
  543. package/dist/src/tools/ripGrep.js.map +1 -1
  544. package/dist/src/tools/ripGrep.test.js +533 -204
  545. package/dist/src/tools/ripGrep.test.js.map +1 -1
  546. package/dist/src/tools/shell.d.ts +8 -6
  547. package/dist/src/tools/shell.js +64 -38
  548. package/dist/src/tools/shell.js.map +1 -1
  549. package/dist/src/tools/shell.test.js +134 -43
  550. package/dist/src/tools/shell.test.js.map +1 -1
  551. package/dist/src/tools/smart-edit.d.ts +10 -23
  552. package/dist/src/tools/smart-edit.js +100 -85
  553. package/dist/src/tools/smart-edit.js.map +1 -1
  554. package/dist/src/tools/smart-edit.test.js +229 -179
  555. package/dist/src/tools/smart-edit.test.js.map +1 -1
  556. package/dist/src/tools/tool-error.d.ts +21 -0
  557. package/dist/src/tools/tool-error.js +27 -0
  558. package/dist/src/tools/tool-error.js.map +1 -1
  559. package/dist/src/tools/tool-names.d.ts +17 -0
  560. package/dist/src/tools/tool-names.js +21 -0
  561. package/dist/src/tools/tool-names.js.map +1 -0
  562. package/dist/src/tools/tool-registry.d.ts +32 -20
  563. package/dist/src/tools/tool-registry.js +122 -78
  564. package/dist/src/tools/tool-registry.js.map +1 -1
  565. package/dist/src/tools/tool-registry.test.js +167 -90
  566. package/dist/src/tools/tool-registry.test.js.map +1 -1
  567. package/dist/src/tools/tools.d.ts +23 -8
  568. package/dist/src/tools/tools.js +69 -37
  569. package/dist/src/tools/tools.js.map +1 -1
  570. package/dist/src/tools/web-fetch.d.ts +11 -3
  571. package/dist/src/tools/web-fetch.js +80 -38
  572. package/dist/src/tools/web-fetch.js.map +1 -1
  573. package/dist/src/tools/web-fetch.test.js +338 -9
  574. package/dist/src/tools/web-fetch.test.js.map +1 -1
  575. package/dist/src/tools/web-search.d.ts +4 -3
  576. package/dist/src/tools/web-search.js +11 -9
  577. package/dist/src/tools/web-search.js.map +1 -1
  578. package/dist/src/tools/web-search.test.js +6 -0
  579. package/dist/src/tools/web-search.test.js.map +1 -1
  580. package/dist/src/tools/write-file.d.ts +3 -2
  581. package/dist/src/tools/write-file.js +41 -40
  582. package/dist/src/tools/write-file.js.map +1 -1
  583. package/dist/src/tools/write-file.test.js +130 -123
  584. package/dist/src/tools/write-file.test.js.map +1 -1
  585. package/dist/src/tools/write-todos.d.ts +34 -9
  586. package/dist/src/tools/write-todos.js +54 -11
  587. package/dist/src/tools/write-todos.js.map +1 -1
  588. package/dist/src/tools/write-todos.test.js +2 -2
  589. package/dist/src/tools/write-todos.test.js.map +1 -1
  590. package/dist/src/utils/bfsFileSearch.js +3 -2
  591. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  592. package/dist/src/utils/channel.d.ts +19 -0
  593. package/dist/src/utils/channel.js +49 -0
  594. package/dist/src/utils/channel.js.map +1 -0
  595. package/dist/src/utils/channel.test.d.ts +6 -0
  596. package/dist/src/utils/channel.test.js +170 -0
  597. package/dist/src/utils/channel.test.js.map +1 -0
  598. package/dist/src/utils/debugLogger.d.ts +25 -0
  599. package/dist/src/utils/debugLogger.js +33 -0
  600. package/dist/src/utils/debugLogger.js.map +1 -0
  601. package/dist/src/utils/debugLogger.test.d.ts +6 -0
  602. package/dist/src/utils/debugLogger.test.js +69 -0
  603. package/dist/src/utils/debugLogger.test.js.map +1 -0
  604. package/dist/src/utils/delay.d.ts +16 -0
  605. package/dist/src/utils/delay.js +43 -0
  606. package/dist/src/utils/delay.js.map +1 -0
  607. package/dist/src/utils/delay.test.d.ts +6 -0
  608. package/dist/src/utils/delay.test.js +88 -0
  609. package/dist/src/utils/delay.test.js.map +1 -0
  610. package/dist/src/utils/editCorrector.js +10 -25
  611. package/dist/src/utils/editCorrector.js.map +1 -1
  612. package/dist/src/utils/editCorrector.test.js +19 -5
  613. package/dist/src/utils/editCorrector.test.js.map +1 -1
  614. package/dist/src/utils/editor.d.ts +4 -2
  615. package/dist/src/utils/editor.js +53 -39
  616. package/dist/src/utils/editor.js.map +1 -1
  617. package/dist/src/utils/editor.test.js +18 -45
  618. package/dist/src/utils/editor.test.js.map +1 -1
  619. package/dist/src/utils/environmentContext.d.ts +2 -1
  620. package/dist/src/utils/environmentContext.js +20 -33
  621. package/dist/src/utils/environmentContext.js.map +1 -1
  622. package/dist/src/utils/environmentContext.test.js +6 -34
  623. package/dist/src/utils/environmentContext.test.js.map +1 -1
  624. package/dist/src/utils/errorParsing.d.ts +1 -1
  625. package/dist/src/utils/errorParsing.js +5 -33
  626. package/dist/src/utils/errorParsing.js.map +1 -1
  627. package/dist/src/utils/errorParsing.test.js +0 -88
  628. package/dist/src/utils/errorParsing.test.js.map +1 -1
  629. package/dist/src/utils/errors.d.ts +3 -0
  630. package/dist/src/utils/errors.js +6 -0
  631. package/dist/src/utils/errors.js.map +1 -1
  632. package/dist/src/utils/events.d.ts +121 -0
  633. package/dist/src/utils/events.js +84 -0
  634. package/dist/src/utils/events.js.map +1 -0
  635. package/dist/src/utils/events.test.d.ts +6 -0
  636. package/dist/src/utils/events.test.js +212 -0
  637. package/dist/src/utils/events.test.js.map +1 -0
  638. package/dist/src/utils/extensionLoader.d.ts +86 -0
  639. package/dist/src/utils/extensionLoader.js +208 -0
  640. package/dist/src/utils/extensionLoader.js.map +1 -0
  641. package/dist/src/utils/extensionLoader.test.d.ts +6 -0
  642. package/dist/src/utils/extensionLoader.test.js +154 -0
  643. package/dist/src/utils/extensionLoader.test.js.map +1 -0
  644. package/dist/src/utils/fetch.d.ts +1 -0
  645. package/dist/src/utils/fetch.js +4 -0
  646. package/dist/src/utils/fetch.js.map +1 -1
  647. package/dist/src/utils/fileUtils.d.ts +4 -0
  648. package/dist/src/utils/fileUtils.js +34 -2
  649. package/dist/src/utils/fileUtils.js.map +1 -1
  650. package/dist/src/utils/fileUtils.test.js +87 -61
  651. package/dist/src/utils/fileUtils.test.js.map +1 -1
  652. package/dist/src/utils/filesearch/fileSearch.js +1 -1
  653. package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
  654. package/dist/src/utils/flashFallback.test.js +28 -47
  655. package/dist/src/utils/flashFallback.test.js.map +1 -1
  656. package/dist/src/utils/formatters.d.ts +1 -0
  657. package/dist/src/utils/formatters.js +2 -1
  658. package/dist/src/utils/formatters.js.map +1 -1
  659. package/dist/src/utils/formatters.test.d.ts +6 -0
  660. package/dist/src/utils/formatters.test.js +26 -0
  661. package/dist/src/utils/formatters.test.js.map +1 -0
  662. package/dist/src/utils/getFolderStructure.js +9 -17
  663. package/dist/src/utils/getFolderStructure.js.map +1 -1
  664. package/dist/src/utils/getFolderStructure.test.js +7 -6
  665. package/dist/src/utils/getFolderStructure.test.js.map +1 -1
  666. package/dist/src/utils/gitIgnoreParser.d.ts +4 -1
  667. package/dist/src/utils/gitIgnoreParser.js +28 -10
  668. package/dist/src/utils/gitIgnoreParser.js.map +1 -1
  669. package/dist/src/utils/gitIgnoreParser.test.js +58 -0
  670. package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
  671. package/dist/src/utils/googleErrors.d.ts +104 -0
  672. package/dist/src/utils/googleErrors.js +152 -0
  673. package/dist/src/utils/googleErrors.js.map +1 -0
  674. package/dist/src/utils/googleErrors.test.d.ts +6 -0
  675. package/dist/src/utils/googleErrors.test.js +301 -0
  676. package/dist/src/utils/googleErrors.test.js.map +1 -0
  677. package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
  678. package/dist/src/utils/googleQuotaErrors.js +157 -0
  679. package/dist/src/utils/googleQuotaErrors.js.map +1 -0
  680. package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
  681. package/dist/src/utils/googleQuotaErrors.test.js +311 -0
  682. package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
  683. package/dist/src/utils/httpErrors.d.ts +18 -0
  684. package/dist/src/utils/httpErrors.js +36 -0
  685. package/dist/src/utils/httpErrors.js.map +1 -0
  686. package/dist/src/utils/ignorePatterns.test.js +26 -30
  687. package/dist/src/utils/ignorePatterns.test.js.map +1 -1
  688. package/dist/src/utils/installationManager.js +2 -1
  689. package/dist/src/utils/installationManager.js.map +1 -1
  690. package/dist/src/utils/installationManager.test.js +6 -4
  691. package/dist/src/utils/installationManager.test.js.map +1 -1
  692. package/dist/src/utils/llm-edit-fixer.d.ts +1 -1
  693. package/dist/src/utils/llm-edit-fixer.js +33 -9
  694. package/dist/src/utils/llm-edit-fixer.js.map +1 -1
  695. package/dist/src/utils/llm-edit-fixer.test.js +38 -1
  696. package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
  697. package/dist/src/utils/memoryDiscovery.d.ts +20 -1
  698. package/dist/src/utils/memoryDiscovery.js +176 -12
  699. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  700. package/dist/src/utils/memoryDiscovery.test.js +299 -40
  701. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  702. package/dist/src/utils/memoryImportProcessor.js +4 -3
  703. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  704. package/dist/src/utils/memoryImportProcessor.test.js +8 -14
  705. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  706. package/dist/src/utils/nextSpeakerChecker.js +3 -3
  707. package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
  708. package/dist/src/utils/nextSpeakerChecker.test.js +13 -5
  709. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
  710. package/dist/src/utils/package.d.ts +12 -0
  711. package/dist/src/utils/package.js +15 -0
  712. package/dist/src/utils/package.js.map +1 -0
  713. package/dist/src/utils/pathCorrector.d.ts +25 -0
  714. package/dist/src/utils/pathCorrector.js +33 -0
  715. package/dist/src/utils/pathCorrector.js.map +1 -0
  716. package/dist/src/utils/pathCorrector.test.d.ts +6 -0
  717. package/dist/src/utils/pathCorrector.test.js +83 -0
  718. package/dist/src/utils/pathCorrector.test.js.map +1 -0
  719. package/dist/src/utils/pathReader.js +4 -4
  720. package/dist/src/utils/pathReader.js.map +1 -1
  721. package/dist/src/utils/pathReader.test.js +44 -1
  722. package/dist/src/utils/pathReader.test.js.map +1 -1
  723. package/dist/src/utils/paths.d.ts +1 -1
  724. package/dist/src/utils/paths.js +131 -29
  725. package/dist/src/utils/paths.js.map +1 -1
  726. package/dist/src/utils/paths.test.js +200 -68
  727. package/dist/src/utils/paths.test.js.map +1 -1
  728. package/dist/src/utils/quotaErrorDetection.d.ts +0 -2
  729. package/dist/src/utils/quotaErrorDetection.js +0 -46
  730. package/dist/src/utils/quotaErrorDetection.js.map +1 -1
  731. package/dist/src/utils/retry.d.ts +3 -10
  732. package/dist/src/utils/retry.js +97 -195
  733. package/dist/src/utils/retry.js.map +1 -1
  734. package/dist/src/utils/retry.test.js +179 -145
  735. package/dist/src/utils/retry.test.js.map +1 -1
  736. package/dist/src/utils/safeJsonStringify.d.ts +4 -4
  737. package/dist/src/utils/safeJsonStringify.js +31 -7
  738. package/dist/src/utils/safeJsonStringify.js.map +1 -1
  739. package/dist/src/utils/shell-utils.d.ts +15 -2
  740. package/dist/src/utils/shell-utils.js +387 -140
  741. package/dist/src/utils/shell-utils.js.map +1 -1
  742. package/dist/src/utils/shell-utils.test.js +244 -62
  743. package/dist/src/utils/shell-utils.test.js.map +1 -1
  744. package/dist/src/utils/stdio.d.ts +32 -0
  745. package/dist/src/utils/stdio.js +85 -0
  746. package/dist/src/utils/stdio.js.map +1 -0
  747. package/dist/src/utils/stdio.test.d.ts +6 -0
  748. package/dist/src/utils/stdio.test.js +47 -0
  749. package/dist/src/utils/stdio.test.js.map +1 -0
  750. package/dist/src/utils/summarizer.d.ts +4 -2
  751. package/dist/src/utils/summarizer.js +8 -9
  752. package/dist/src/utils/summarizer.js.map +1 -1
  753. package/dist/src/utils/summarizer.test.js +32 -12
  754. package/dist/src/utils/summarizer.test.js.map +1 -1
  755. package/dist/src/utils/systemEncoding.js +5 -4
  756. package/dist/src/utils/systemEncoding.js.map +1 -1
  757. package/dist/src/utils/systemEncoding.test.js +2 -1
  758. package/dist/src/utils/systemEncoding.test.js.map +1 -1
  759. package/dist/src/utils/terminal.d.ts +14 -0
  760. package/dist/src/utils/terminal.js +38 -0
  761. package/dist/src/utils/terminal.js.map +1 -0
  762. package/dist/src/utils/tool-utils.d.ts +2 -2
  763. package/dist/src/utils/tool-utils.js +15 -6
  764. package/dist/src/utils/tool-utils.js.map +1 -1
  765. package/dist/src/utils/tool-utils.test.js +8 -0
  766. package/dist/src/utils/tool-utils.test.js.map +1 -1
  767. package/dist/src/utils/userAccountManager.js +5 -4
  768. package/dist/src/utils/userAccountManager.js.map +1 -1
  769. package/dist/src/utils/userAccountManager.test.js +9 -7
  770. package/dist/src/utils/userAccountManager.test.js.map +1 -1
  771. package/dist/src/utils/workspaceContext.d.ts +4 -3
  772. package/dist/src/utils/workspaceContext.js +13 -13
  773. package/dist/src/utils/workspaceContext.js.map +1 -1
  774. package/dist/src/utils/workspaceContext.test.js +8 -7
  775. package/dist/src/utils/workspaceContext.test.js.map +1 -1
  776. package/dist/tsconfig.tsbuildinfo +1 -1
  777. package/package.json +12 -7
@@ -6,7 +6,8 @@
6
6
  import { describe, it, expect, vi, beforeEach } from 'vitest';
7
7
  import { FileOperation, MemoryMetricType, ToolExecutionPhase, ApiRequestPhase, } from './metrics.js';
8
8
  import { makeFakeConfig } from '../test-utils/config.js';
9
- import { ModelRoutingEvent } from './types.js';
9
+ import { ModelRoutingEvent, AgentFinishEvent } from './types.js';
10
+ import { AgentTerminateMode } from '../agents/types.js';
10
11
  const mockCounterAddFn = vi.fn();
11
12
  const mockHistogramRecordFn = vi.fn();
12
13
  const mockCreateCounterFn = vi.fn();
@@ -34,9 +35,15 @@ function originalOtelMockFactory() {
34
35
  setLogger: vi.fn(),
35
36
  warn: vi.fn(),
36
37
  },
38
+ DiagConsoleLogger: vi.fn(),
39
+ DiagLogLevel: {
40
+ NONE: 0,
41
+ INFO: 1,
42
+ },
37
43
  };
38
44
  }
39
45
  vi.mock('@opentelemetry/api');
46
+ vi.mock('./telemetryAttributes.js');
40
47
  describe('Telemetry Metrics', () => {
41
48
  let initializeMetricsModule;
42
49
  let recordTokenUsageMetricsModule;
@@ -53,6 +60,13 @@ describe('Telemetry Metrics', () => {
53
60
  let recordPerformanceScoreModule;
54
61
  let recordPerformanceRegressionModule;
55
62
  let recordBaselineComparisonModule;
63
+ let recordGenAiClientTokenUsageModule;
64
+ let recordGenAiClientOperationDurationModule;
65
+ let recordFlickerFrameModule;
66
+ let recordExitFailModule;
67
+ let recordAgentRunMetricsModule;
68
+ let recordLinesChangedModule;
69
+ let recordSlowRenderModule;
56
70
  beforeEach(async () => {
57
71
  vi.resetModules();
58
72
  vi.doMock('@opentelemetry/api', () => {
@@ -60,6 +74,12 @@ describe('Telemetry Metrics', () => {
60
74
  actualApi.metrics.getMeter.mockReturnValue(mockMeterInstance);
61
75
  return actualApi;
62
76
  });
77
+ const { getCommonAttributes } = await import('./telemetryAttributes.js');
78
+ getCommonAttributes.mockReturnValue({
79
+ 'session.id': 'test-session-id',
80
+ 'installation.id': 'test-installation-id',
81
+ 'user.email': 'test@example.com',
82
+ });
63
83
  const metricsJsModule = await import('./metrics.js');
64
84
  initializeMetricsModule = metricsJsModule.initializeMetrics;
65
85
  recordTokenUsageMetricsModule = metricsJsModule.recordTokenUsageMetrics;
@@ -79,6 +99,15 @@ describe('Telemetry Metrics', () => {
79
99
  recordPerformanceRegressionModule =
80
100
  metricsJsModule.recordPerformanceRegression;
81
101
  recordBaselineComparisonModule = metricsJsModule.recordBaselineComparison;
102
+ recordGenAiClientTokenUsageModule =
103
+ metricsJsModule.recordGenAiClientTokenUsage;
104
+ recordGenAiClientOperationDurationModule =
105
+ metricsJsModule.recordGenAiClientOperationDuration;
106
+ recordFlickerFrameModule = metricsJsModule.recordFlickerFrame;
107
+ recordExitFailModule = metricsJsModule.recordExitFail;
108
+ recordAgentRunMetricsModule = metricsJsModule.recordAgentRunMetrics;
109
+ recordLinesChangedModule = metricsJsModule.recordLinesChanged;
110
+ recordSlowRenderModule = metricsJsModule.recordSlowRender;
82
111
  const otelApiModule = await import('@opentelemetry/api');
83
112
  mockCounterAddFn.mockClear();
84
113
  mockCreateCounterFn.mockClear();
@@ -89,6 +118,75 @@ describe('Telemetry Metrics', () => {
89
118
  mockCreateCounterFn.mockReturnValue(mockCounterInstance);
90
119
  mockCreateHistogramFn.mockReturnValue(mockHistogramInstance);
91
120
  });
121
+ describe('recordFlickerFrame', () => {
122
+ it('does not record metrics if not initialized', () => {
123
+ const config = makeFakeConfig({});
124
+ recordFlickerFrameModule(config);
125
+ expect(mockCounterAddFn).not.toHaveBeenCalled();
126
+ });
127
+ it('records a flicker frame event when initialized', () => {
128
+ const config = makeFakeConfig({});
129
+ initializeMetricsModule(config);
130
+ recordFlickerFrameModule(config);
131
+ // Called for session, then for flicker
132
+ expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
133
+ expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
134
+ 'session.id': 'test-session-id',
135
+ 'installation.id': 'test-installation-id',
136
+ 'user.email': 'test@example.com',
137
+ });
138
+ });
139
+ });
140
+ describe('recordExitFail', () => {
141
+ it('does not record metrics if not initialized', () => {
142
+ const config = makeFakeConfig({});
143
+ recordExitFailModule(config);
144
+ expect(mockCounterAddFn).not.toHaveBeenCalled();
145
+ });
146
+ it('records a exit fail event when initialized', () => {
147
+ const config = makeFakeConfig({});
148
+ initializeMetricsModule(config);
149
+ recordExitFailModule(config);
150
+ // Called for session, then for exit fail
151
+ expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
152
+ expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
153
+ 'session.id': 'test-session-id',
154
+ 'installation.id': 'test-installation-id',
155
+ 'user.email': 'test@example.com',
156
+ });
157
+ });
158
+ });
159
+ describe('recordSlowRender', () => {
160
+ it('does not record metrics if not initialized', () => {
161
+ const config = makeFakeConfig({});
162
+ recordSlowRenderModule(config, 123);
163
+ expect(mockHistogramRecordFn).not.toHaveBeenCalled();
164
+ });
165
+ it('records a slow render event when initialized', () => {
166
+ const config = makeFakeConfig({});
167
+ initializeMetricsModule(config);
168
+ recordSlowRenderModule(config, 123);
169
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(123, {
170
+ 'session.id': 'test-session-id',
171
+ 'installation.id': 'test-installation-id',
172
+ 'user.email': 'test@example.com',
173
+ });
174
+ });
175
+ });
176
+ describe('initializeMetrics', () => {
177
+ const mockConfig = {
178
+ getSessionId: () => 'test-session-id',
179
+ getTelemetryEnabled: () => true,
180
+ };
181
+ it('should apply common attributes including email', () => {
182
+ initializeMetricsModule(mockConfig);
183
+ expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
184
+ 'session.id': 'test-session-id',
185
+ 'installation.id': 'test-installation-id',
186
+ 'user.email': 'test@example.com',
187
+ });
188
+ });
189
+ });
92
190
  describe('recordChatCompressionMetrics', () => {
93
191
  it('does not record metrics if not initialized', () => {
94
192
  const lol = makeFakeConfig({});
@@ -107,6 +205,8 @@ describe('Telemetry Metrics', () => {
107
205
  });
108
206
  expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
109
207
  'session.id': 'test-session-id',
208
+ 'installation.id': 'test-installation-id',
209
+ 'user.email': 'test@example.com',
110
210
  tokens_after: 100,
111
211
  tokens_before: 200,
112
212
  });
@@ -124,172 +224,139 @@ describe('Telemetry Metrics', () => {
124
224
  });
125
225
  expect(mockCounterAddFn).not.toHaveBeenCalled();
126
226
  });
127
- it('should record token usage with the correct attributes', () => {
128
- initializeMetricsModule(mockConfig);
129
- recordTokenUsageMetricsModule(mockConfig, 100, {
130
- model: 'gemini-pro',
131
- type: 'input',
132
- });
133
- expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
134
- expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
135
- 'session.id': 'test-session-id',
136
- });
137
- expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 100, {
138
- 'session.id': 'test-session-id',
139
- model: 'gemini-pro',
140
- type: 'input',
141
- });
142
- });
143
- it('should record token usage for different types', () => {
227
+ it.each([
228
+ { type: 'input', tokens: 100, model: 'gemini-pro' },
229
+ { type: 'output', tokens: 50, model: 'gemini-pro' },
230
+ { type: 'thought', tokens: 25, model: 'gemini-pro' },
231
+ { type: 'cache', tokens: 75, model: 'gemini-pro' },
232
+ { type: 'tool', tokens: 125, model: 'gemini-pro' },
233
+ { type: 'input', tokens: 200, model: 'gemini-different-model' },
234
+ ])('should record token usage for $type type with $tokens tokens for model $model', ({ type, tokens, model }) => {
144
235
  initializeMetricsModule(mockConfig);
145
236
  mockCounterAddFn.mockClear();
146
- recordTokenUsageMetricsModule(mockConfig, 50, {
147
- model: 'gemini-pro',
148
- type: 'output',
149
- });
150
- expect(mockCounterAddFn).toHaveBeenCalledWith(50, {
151
- 'session.id': 'test-session-id',
152
- model: 'gemini-pro',
153
- type: 'output',
154
- });
155
- recordTokenUsageMetricsModule(mockConfig, 25, {
156
- model: 'gemini-pro',
157
- type: 'thought',
237
+ recordTokenUsageMetricsModule(mockConfig, tokens, {
238
+ model,
239
+ type: type,
158
240
  });
159
- expect(mockCounterAddFn).toHaveBeenCalledWith(25, {
241
+ expect(mockCounterAddFn).toHaveBeenCalledWith(tokens, {
160
242
  'session.id': 'test-session-id',
161
- model: 'gemini-pro',
162
- type: 'thought',
163
- });
164
- recordTokenUsageMetricsModule(mockConfig, 75, {
165
- model: 'gemini-pro',
166
- type: 'cache',
167
- });
168
- expect(mockCounterAddFn).toHaveBeenCalledWith(75, {
169
- 'session.id': 'test-session-id',
170
- model: 'gemini-pro',
171
- type: 'cache',
172
- });
173
- recordTokenUsageMetricsModule(mockConfig, 125, {
174
- model: 'gemini-pro',
175
- type: 'tool',
176
- });
177
- expect(mockCounterAddFn).toHaveBeenCalledWith(125, {
178
- 'session.id': 'test-session-id',
179
- model: 'gemini-pro',
180
- type: 'tool',
181
- });
182
- });
183
- it('should handle different models', () => {
184
- initializeMetricsModule(mockConfig);
185
- mockCounterAddFn.mockClear();
186
- recordTokenUsageMetricsModule(mockConfig, 200, {
187
- model: 'gemini-ultra',
188
- type: 'input',
189
- });
190
- expect(mockCounterAddFn).toHaveBeenCalledWith(200, {
191
- 'session.id': 'test-session-id',
192
- model: 'gemini-ultra',
193
- type: 'input',
243
+ 'installation.id': 'test-installation-id',
244
+ 'user.email': 'test@example.com',
245
+ model,
246
+ type,
194
247
  });
195
248
  });
196
249
  });
197
- describe('recordFileOperationMetric', () => {
250
+ describe('recordLinesChanged metric', () => {
198
251
  const mockConfig = {
199
252
  getSessionId: () => 'test-session-id',
200
253
  getTelemetryEnabled: () => true,
201
254
  };
202
- it('should not record metrics if not initialized', () => {
203
- recordFileOperationMetricModule(mockConfig, {
204
- operation: FileOperation.CREATE,
205
- lines: 10,
206
- mimetype: 'text/plain',
207
- extension: 'txt',
208
- });
209
- expect(mockCounterAddFn).not.toHaveBeenCalled();
210
- });
211
- it('should record file creation with all attributes', () => {
212
- initializeMetricsModule(mockConfig);
213
- recordFileOperationMetricModule(mockConfig, {
214
- operation: FileOperation.CREATE,
215
- lines: 10,
216
- mimetype: 'text/plain',
217
- extension: 'txt',
218
- });
219
- expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
220
- expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
221
- 'session.id': 'test-session-id',
255
+ it('should not record lines added/removed if not initialized', () => {
256
+ recordLinesChangedModule(mockConfig, 10, 'added', {
257
+ function_name: 'fn',
222
258
  });
223
- expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
224
- 'session.id': 'test-session-id',
225
- operation: FileOperation.CREATE,
226
- lines: 10,
227
- mimetype: 'text/plain',
228
- extension: 'txt',
229
- });
230
- });
231
- it('should record file read with minimal attributes', () => {
232
- initializeMetricsModule(mockConfig);
233
- mockCounterAddFn.mockClear();
234
- recordFileOperationMetricModule(mockConfig, {
235
- operation: FileOperation.READ,
236
- });
237
- expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
238
- 'session.id': 'test-session-id',
239
- operation: FileOperation.READ,
240
- });
241
- });
242
- it('should record file update with some attributes', () => {
243
- initializeMetricsModule(mockConfig);
244
- mockCounterAddFn.mockClear();
245
- recordFileOperationMetricModule(mockConfig, {
246
- operation: FileOperation.UPDATE,
247
- mimetype: 'application/javascript',
248
- });
249
- expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
250
- 'session.id': 'test-session-id',
251
- operation: FileOperation.UPDATE,
252
- mimetype: 'application/javascript',
259
+ recordLinesChangedModule(mockConfig, 5, 'removed', {
260
+ function_name: 'fn',
253
261
  });
262
+ expect(mockCounterAddFn).not.toHaveBeenCalled();
254
263
  });
255
- it('should record file operation without diffStat', () => {
264
+ it('should record lines added with function_name after initialization', () => {
256
265
  initializeMetricsModule(mockConfig);
257
266
  mockCounterAddFn.mockClear();
258
- recordFileOperationMetricModule(mockConfig, {
259
- operation: FileOperation.UPDATE,
267
+ recordLinesChangedModule(mockConfig, 10, 'added', {
268
+ function_name: 'my-fn',
260
269
  });
261
- expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
270
+ expect(mockCounterAddFn).toHaveBeenCalledWith(10, {
262
271
  'session.id': 'test-session-id',
263
- operation: FileOperation.UPDATE,
272
+ 'installation.id': 'test-installation-id',
273
+ 'user.email': 'test@example.com',
274
+ type: 'added',
275
+ function_name: 'my-fn',
264
276
  });
265
277
  });
266
- it('should record minimal file operation when optional parameters are undefined', () => {
278
+ it('should record lines removed with function_name after initialization', () => {
267
279
  initializeMetricsModule(mockConfig);
268
280
  mockCounterAddFn.mockClear();
269
- recordFileOperationMetricModule(mockConfig, {
270
- operation: FileOperation.UPDATE,
271
- lines: 10,
272
- mimetype: 'text/plain',
273
- extension: 'txt',
281
+ recordLinesChangedModule(mockConfig, 7, 'removed', {
282
+ function_name: 'my-fn',
274
283
  });
275
- expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
284
+ expect(mockCounterAddFn).toHaveBeenCalledWith(7, {
276
285
  'session.id': 'test-session-id',
277
- operation: FileOperation.UPDATE,
278
- lines: 10,
279
- mimetype: 'text/plain',
280
- extension: 'txt',
286
+ 'installation.id': 'test-installation-id',
287
+ 'user.email': 'test@example.com',
288
+ type: 'removed',
289
+ function_name: 'my-fn',
281
290
  });
282
291
  });
283
- it('should not include diffStat attributes when diffStat is not provided', () => {
284
- initializeMetricsModule(mockConfig);
285
- mockCounterAddFn.mockClear();
286
- recordFileOperationMetricModule(mockConfig, {
287
- operation: FileOperation.UPDATE,
288
- });
289
- expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
290
- 'session.id': 'test-session-id',
291
- operation: FileOperation.UPDATE,
292
- });
292
+ });
293
+ describe('recordFileOperationMetric', () => {
294
+ const mockConfig = {
295
+ getSessionId: () => 'test-session-id',
296
+ getTelemetryEnabled: () => true,
297
+ };
298
+ it.each([
299
+ {
300
+ name: 'should not record metrics if not initialized',
301
+ initialized: false,
302
+ attributes: {
303
+ operation: FileOperation.CREATE,
304
+ lines: 10,
305
+ mimetype: 'text/plain',
306
+ extension: 'txt',
307
+ },
308
+ shouldCall: false,
309
+ },
310
+ {
311
+ name: 'should record file creation with all attributes',
312
+ initialized: true,
313
+ attributes: {
314
+ operation: FileOperation.CREATE,
315
+ lines: 10,
316
+ mimetype: 'text/plain',
317
+ extension: 'txt',
318
+ },
319
+ shouldCall: true,
320
+ },
321
+ {
322
+ name: 'should record file read with minimal attributes',
323
+ initialized: true,
324
+ attributes: { operation: FileOperation.READ },
325
+ shouldCall: true,
326
+ },
327
+ {
328
+ name: 'should record file update with some attributes',
329
+ initialized: true,
330
+ attributes: {
331
+ operation: FileOperation.UPDATE,
332
+ mimetype: 'application/javascript',
333
+ },
334
+ shouldCall: true,
335
+ },
336
+ {
337
+ name: 'should record file update with no optional attributes',
338
+ initialized: true,
339
+ attributes: { operation: FileOperation.UPDATE },
340
+ shouldCall: true,
341
+ },
342
+ ])('$name', ({ initialized, attributes, shouldCall }) => {
343
+ if (initialized) {
344
+ initializeMetricsModule(mockConfig);
345
+ // The session start event also calls the counter.
346
+ mockCounterAddFn.mockClear();
347
+ }
348
+ recordFileOperationMetricModule(mockConfig, attributes);
349
+ if (shouldCall) {
350
+ expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
351
+ 'session.id': 'test-session-id',
352
+ 'installation.id': 'test-installation-id',
353
+ 'user.email': 'test@example.com',
354
+ ...attributes,
355
+ });
356
+ }
357
+ else {
358
+ expect(mockCounterAddFn).not.toHaveBeenCalled();
359
+ }
293
360
  });
294
361
  });
295
362
  describe('recordModelRoutingMetrics', () => {
@@ -309,6 +376,8 @@ describe('Telemetry Metrics', () => {
309
376
  recordModelRoutingMetricsModule(mockConfig, event);
310
377
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
311
378
  'session.id': 'test-session-id',
379
+ 'installation.id': 'test-installation-id',
380
+ 'user.email': 'test@example.com',
312
381
  'routing.decision_model': 'gemini-pro',
313
382
  'routing.decision_source': 'default',
314
383
  });
@@ -321,17 +390,226 @@ describe('Telemetry Metrics', () => {
321
390
  recordModelRoutingMetricsModule(mockConfig, event);
322
391
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
323
392
  'session.id': 'test-session-id',
393
+ 'installation.id': 'test-installation-id',
394
+ 'user.email': 'test@example.com',
324
395
  'routing.decision_model': 'gemini-pro',
325
396
  'routing.decision_source': 'classifier',
326
397
  });
327
398
  expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
328
399
  expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
329
400
  'session.id': 'test-session-id',
401
+ 'installation.id': 'test-installation-id',
402
+ 'user.email': 'test@example.com',
330
403
  'routing.decision_source': 'classifier',
331
404
  'routing.error_message': 'test-error',
332
405
  });
333
406
  });
334
407
  });
408
+ describe('recordAgentRunMetrics', () => {
409
+ const mockConfig = {
410
+ getSessionId: () => 'test-session-id',
411
+ getTelemetryEnabled: () => true,
412
+ };
413
+ it('should not record metrics if not initialized', () => {
414
+ const event = new AgentFinishEvent('agent-123', 'TestAgent', 1000, 5, AgentTerminateMode.GOAL);
415
+ recordAgentRunMetricsModule(mockConfig, event);
416
+ expect(mockCounterAddFn).not.toHaveBeenCalled();
417
+ expect(mockHistogramRecordFn).not.toHaveBeenCalled();
418
+ });
419
+ it('should record agent run metrics', () => {
420
+ initializeMetricsModule(mockConfig);
421
+ mockCounterAddFn.mockClear();
422
+ mockHistogramRecordFn.mockClear();
423
+ const event = new AgentFinishEvent('agent-123', 'TestAgent', 1000, 5, AgentTerminateMode.GOAL);
424
+ recordAgentRunMetricsModule(mockConfig, event);
425
+ // Verify agent run counter
426
+ expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
427
+ 'session.id': 'test-session-id',
428
+ 'installation.id': 'test-installation-id',
429
+ 'user.email': 'test@example.com',
430
+ agent_name: 'TestAgent',
431
+ terminate_reason: 'GOAL',
432
+ });
433
+ // Verify agent duration histogram
434
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(1000, {
435
+ 'session.id': 'test-session-id',
436
+ 'installation.id': 'test-installation-id',
437
+ 'user.email': 'test@example.com',
438
+ agent_name: 'TestAgent',
439
+ });
440
+ // Verify agent turns histogram
441
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(5, {
442
+ 'session.id': 'test-session-id',
443
+ 'installation.id': 'test-installation-id',
444
+ 'user.email': 'test@example.com',
445
+ agent_name: 'TestAgent',
446
+ });
447
+ });
448
+ });
449
+ describe('OpenTelemetry GenAI Semantic Convention Metrics', () => {
450
+ const mockConfig = {
451
+ getSessionId: () => 'test-session-id',
452
+ getTelemetryEnabled: () => true,
453
+ };
454
+ describe('recordGenAiClientTokenUsage', () => {
455
+ it('should not record metrics when not initialized', () => {
456
+ recordGenAiClientTokenUsageModule(mockConfig, 100, {
457
+ 'gen_ai.operation.name': 'generate_content',
458
+ 'gen_ai.provider.name': 'gcp.gen_ai',
459
+ 'gen_ai.token.type': 'input',
460
+ });
461
+ expect(mockHistogramRecordFn).not.toHaveBeenCalled();
462
+ });
463
+ it('should record input token usage with correct attributes', () => {
464
+ initializeMetricsModule(mockConfig);
465
+ mockHistogramRecordFn.mockClear();
466
+ recordGenAiClientTokenUsageModule(mockConfig, 150, {
467
+ 'gen_ai.operation.name': 'generate_content',
468
+ 'gen_ai.provider.name': 'gcp.gen_ai',
469
+ 'gen_ai.token.type': 'input',
470
+ 'gen_ai.request.model': 'gemini-2.0-flash',
471
+ 'gen_ai.response.model': 'gemini-2.0-flash',
472
+ });
473
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
474
+ 'session.id': 'test-session-id',
475
+ 'installation.id': 'test-installation-id',
476
+ 'user.email': 'test@example.com',
477
+ 'gen_ai.operation.name': 'generate_content',
478
+ 'gen_ai.provider.name': 'gcp.gen_ai',
479
+ 'gen_ai.token.type': 'input',
480
+ 'gen_ai.request.model': 'gemini-2.0-flash',
481
+ 'gen_ai.response.model': 'gemini-2.0-flash',
482
+ });
483
+ });
484
+ it('should record output token usage with correct attributes', () => {
485
+ initializeMetricsModule(mockConfig);
486
+ mockHistogramRecordFn.mockClear();
487
+ recordGenAiClientTokenUsageModule(mockConfig, 75, {
488
+ 'gen_ai.operation.name': 'generate_content',
489
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
490
+ 'gen_ai.token.type': 'output',
491
+ 'gen_ai.request.model': 'gemini-pro',
492
+ });
493
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(75, {
494
+ 'session.id': 'test-session-id',
495
+ 'installation.id': 'test-installation-id',
496
+ 'user.email': 'test@example.com',
497
+ 'gen_ai.operation.name': 'generate_content',
498
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
499
+ 'gen_ai.token.type': 'output',
500
+ 'gen_ai.request.model': 'gemini-pro',
501
+ });
502
+ });
503
+ it('should record token usage with optional attributes', () => {
504
+ initializeMetricsModule(mockConfig);
505
+ mockHistogramRecordFn.mockClear();
506
+ recordGenAiClientTokenUsageModule(mockConfig, 200, {
507
+ 'gen_ai.operation.name': 'generate_content',
508
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
509
+ 'gen_ai.token.type': 'input',
510
+ 'gen_ai.request.model': 'text-embedding-004',
511
+ 'server.address': 'aiplatform.googleapis.com',
512
+ 'server.port': 443,
513
+ });
514
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
515
+ 'session.id': 'test-session-id',
516
+ 'installation.id': 'test-installation-id',
517
+ 'user.email': 'test@example.com',
518
+ 'gen_ai.operation.name': 'generate_content',
519
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
520
+ 'gen_ai.token.type': 'input',
521
+ 'gen_ai.request.model': 'text-embedding-004',
522
+ 'server.address': 'aiplatform.googleapis.com',
523
+ 'server.port': 443,
524
+ });
525
+ });
526
+ });
527
+ describe('recordGenAiClientOperationDuration', () => {
528
+ it('should not record metrics when not initialized', () => {
529
+ recordGenAiClientOperationDurationModule(mockConfig, 2.5, {
530
+ 'gen_ai.operation.name': 'generate_content',
531
+ 'gen_ai.provider.name': 'gcp.gen_ai',
532
+ });
533
+ expect(mockHistogramRecordFn).not.toHaveBeenCalled();
534
+ });
535
+ it('should record successful operation duration with correct attributes', () => {
536
+ initializeMetricsModule(mockConfig);
537
+ mockHistogramRecordFn.mockClear();
538
+ recordGenAiClientOperationDurationModule(mockConfig, 1.25, {
539
+ 'gen_ai.operation.name': 'generate_content',
540
+ 'gen_ai.provider.name': 'gcp.gen_ai',
541
+ 'gen_ai.request.model': 'gemini-2.0-flash',
542
+ 'gen_ai.response.model': 'gemini-2.0-flash',
543
+ });
544
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(1.25, {
545
+ 'session.id': 'test-session-id',
546
+ 'installation.id': 'test-installation-id',
547
+ 'user.email': 'test@example.com',
548
+ 'gen_ai.operation.name': 'generate_content',
549
+ 'gen_ai.provider.name': 'gcp.gen_ai',
550
+ 'gen_ai.request.model': 'gemini-2.0-flash',
551
+ 'gen_ai.response.model': 'gemini-2.0-flash',
552
+ });
553
+ });
554
+ it('should record failed operation duration with error type', () => {
555
+ initializeMetricsModule(mockConfig);
556
+ mockHistogramRecordFn.mockClear();
557
+ recordGenAiClientOperationDurationModule(mockConfig, 3.75, {
558
+ 'gen_ai.operation.name': 'generate_content',
559
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
560
+ 'gen_ai.request.model': 'gemini-pro',
561
+ 'error.type': 'quota_exceeded',
562
+ });
563
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(3.75, {
564
+ 'session.id': 'test-session-id',
565
+ 'installation.id': 'test-installation-id',
566
+ 'user.email': 'test@example.com',
567
+ 'gen_ai.operation.name': 'generate_content',
568
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
569
+ 'gen_ai.request.model': 'gemini-pro',
570
+ 'error.type': 'quota_exceeded',
571
+ });
572
+ });
573
+ it('should record operation duration with server details', () => {
574
+ initializeMetricsModule(mockConfig);
575
+ mockHistogramRecordFn.mockClear();
576
+ recordGenAiClientOperationDurationModule(mockConfig, 0.95, {
577
+ 'gen_ai.operation.name': 'generate_content',
578
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
579
+ 'gen_ai.request.model': 'gemini-1.5-pro',
580
+ 'gen_ai.response.model': 'gemini-1.5-pro-001',
581
+ 'server.address': 'us-central1-aiplatform.googleapis.com',
582
+ 'server.port': 443,
583
+ });
584
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.95, {
585
+ 'session.id': 'test-session-id',
586
+ 'installation.id': 'test-installation-id',
587
+ 'user.email': 'test@example.com',
588
+ 'gen_ai.operation.name': 'generate_content',
589
+ 'gen_ai.provider.name': 'gcp.vertex_ai',
590
+ 'gen_ai.request.model': 'gemini-1.5-pro',
591
+ 'gen_ai.response.model': 'gemini-1.5-pro-001',
592
+ 'server.address': 'us-central1-aiplatform.googleapis.com',
593
+ 'server.port': 443,
594
+ });
595
+ });
596
+ it('should handle minimal required attributes', () => {
597
+ initializeMetricsModule(mockConfig);
598
+ mockHistogramRecordFn.mockClear();
599
+ recordGenAiClientOperationDurationModule(mockConfig, 2.1, {
600
+ 'gen_ai.operation.name': 'generate_content',
601
+ 'gen_ai.provider.name': 'gcp.gen_ai',
602
+ });
603
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(2.1, {
604
+ 'session.id': 'test-session-id',
605
+ 'installation.id': 'test-installation-id',
606
+ 'user.email': 'test@example.com',
607
+ 'gen_ai.operation.name': 'generate_content',
608
+ 'gen_ai.provider.name': 'gcp.gen_ai',
609
+ });
610
+ });
611
+ });
612
+ });
335
613
  describe('Performance Monitoring Metrics', () => {
336
614
  const mockConfig = {
337
615
  getSessionId: () => 'test-session-id',
@@ -367,6 +645,8 @@ describe('Telemetry Metrics', () => {
367
645
  });
368
646
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
369
647
  'session.id': 'test-session-id',
648
+ 'installation.id': 'test-installation-id',
649
+ 'user.email': 'test@example.com',
370
650
  phase: 'settings_loading',
371
651
  auth_type: 'gemini',
372
652
  telemetry_enabled: true,
@@ -379,6 +659,8 @@ describe('Telemetry Metrics', () => {
379
659
  recordStartupPerformanceModule(mockConfig, 50, { phase: 'cleanup' });
380
660
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(50, {
381
661
  'session.id': 'test-session-id',
662
+ 'installation.id': 'test-installation-id',
663
+ 'user.email': 'test@example.com',
382
664
  phase: 'cleanup',
383
665
  });
384
666
  });
@@ -396,6 +678,8 @@ describe('Telemetry Metrics', () => {
396
678
  });
397
679
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(floatingPointDuration, {
398
680
  'session.id': 'test-session-id',
681
+ 'installation.id': 'test-installation-id',
682
+ 'user.email': 'test@example.com',
399
683
  phase: 'total_startup',
400
684
  is_tty: true,
401
685
  has_question: false,
@@ -403,61 +687,49 @@ describe('Telemetry Metrics', () => {
403
687
  });
404
688
  });
405
689
  describe('recordMemoryUsage', () => {
406
- it('should record memory usage for different memory types', () => {
407
- initializeMetricsModule(mockConfig);
408
- mockHistogramRecordFn.mockClear();
409
- recordMemoryUsageModule(mockConfig, 15728640, {
690
+ it.each([
691
+ {
410
692
  memory_type: MemoryMetricType.HEAP_USED,
411
693
  component: 'startup',
412
- });
413
- expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
414
- 'session.id': 'test-session-id',
415
- memory_type: 'heap_used',
416
- component: 'startup',
417
- });
418
- });
419
- it('should record memory usage for all memory metric types', () => {
420
- initializeMetricsModule(mockConfig);
421
- mockHistogramRecordFn.mockClear();
422
- recordMemoryUsageModule(mockConfig, 31457280, {
694
+ value: 15728640,
695
+ },
696
+ {
423
697
  memory_type: MemoryMetricType.HEAP_TOTAL,
424
698
  component: 'api_call',
425
- });
426
- recordMemoryUsageModule(mockConfig, 2097152, {
699
+ value: 31457280,
700
+ },
701
+ {
427
702
  memory_type: MemoryMetricType.EXTERNAL,
428
703
  component: 'tool_execution',
429
- });
430
- recordMemoryUsageModule(mockConfig, 41943040, {
704
+ value: 2097152,
705
+ },
706
+ {
431
707
  memory_type: MemoryMetricType.RSS,
432
708
  component: 'memory_monitor',
433
- });
434
- expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
435
- expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 31457280, {
436
- 'session.id': 'test-session-id',
437
- memory_type: 'heap_total',
438
- component: 'api_call',
439
- });
440
- expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 2097152, {
441
- 'session.id': 'test-session-id',
442
- memory_type: 'external',
443
- component: 'tool_execution',
444
- });
445
- expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 41943040, {
446
- 'session.id': 'test-session-id',
447
- memory_type: 'rss',
448
- component: 'memory_monitor',
449
- });
450
- });
451
- it('should record memory usage without component', () => {
709
+ value: 41943040,
710
+ },
711
+ {
712
+ memory_type: MemoryMetricType.HEAP_USED,
713
+ component: undefined,
714
+ value: 15728640,
715
+ },
716
+ ])('should record memory usage for $memory_type', ({ memory_type, component, value }) => {
452
717
  initializeMetricsModule(mockConfig);
453
718
  mockHistogramRecordFn.mockClear();
454
- recordMemoryUsageModule(mockConfig, 15728640, {
455
- memory_type: MemoryMetricType.HEAP_USED,
719
+ recordMemoryUsageModule(mockConfig, value, {
720
+ memory_type,
721
+ component,
456
722
  });
457
- expect(mockHistogramRecordFn).toHaveBeenCalledWith(15728640, {
723
+ const expectedAttributes = {
458
724
  'session.id': 'test-session-id',
459
- memory_type: 'heap_used',
460
- });
725
+ 'installation.id': 'test-installation-id',
726
+ 'user.email': 'test@example.com',
727
+ memory_type,
728
+ };
729
+ if (component) {
730
+ expectedAttributes['component'] = component;
731
+ }
732
+ expect(mockHistogramRecordFn).toHaveBeenCalledWith(value, expectedAttributes);
461
733
  });
462
734
  });
463
735
  describe('recordCpuUsage', () => {
@@ -469,6 +741,8 @@ describe('Telemetry Metrics', () => {
469
741
  });
470
742
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
471
743
  'session.id': 'test-session-id',
744
+ 'installation.id': 'test-installation-id',
745
+ 'user.email': 'test@example.com',
472
746
  component: 'tool_execution',
473
747
  });
474
748
  });
@@ -478,6 +752,8 @@ describe('Telemetry Metrics', () => {
478
752
  recordCpuUsageModule(mockConfig, 42.3, {});
479
753
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(42.3, {
480
754
  'session.id': 'test-session-id',
755
+ 'installation.id': 'test-installation-id',
756
+ 'user.email': 'test@example.com',
481
757
  });
482
758
  });
483
759
  });
@@ -488,6 +764,8 @@ describe('Telemetry Metrics', () => {
488
764
  recordToolQueueDepthModule(mockConfig, 3);
489
765
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(3, {
490
766
  'session.id': 'test-session-id',
767
+ 'installation.id': 'test-installation-id',
768
+ 'user.email': 'test@example.com',
491
769
  });
492
770
  });
493
771
  it('should record zero queue depth', () => {
@@ -496,6 +774,8 @@ describe('Telemetry Metrics', () => {
496
774
  recordToolQueueDepthModule(mockConfig, 0);
497
775
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(0, {
498
776
  'session.id': 'test-session-id',
777
+ 'installation.id': 'test-installation-id',
778
+ 'user.email': 'test@example.com',
499
779
  });
500
780
  });
501
781
  });
@@ -509,6 +789,8 @@ describe('Telemetry Metrics', () => {
509
789
  });
510
790
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(25, {
511
791
  'session.id': 'test-session-id',
792
+ 'installation.id': 'test-installation-id',
793
+ 'user.email': 'test@example.com',
512
794
  function_name: 'Read',
513
795
  phase: 'validation',
514
796
  });
@@ -531,16 +813,22 @@ describe('Telemetry Metrics', () => {
531
813
  expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
532
814
  expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 50, {
533
815
  'session.id': 'test-session-id',
816
+ 'installation.id': 'test-installation-id',
817
+ 'user.email': 'test@example.com',
534
818
  function_name: 'Bash',
535
819
  phase: 'preparation',
536
820
  });
537
821
  expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 1500, {
538
822
  'session.id': 'test-session-id',
823
+ 'installation.id': 'test-installation-id',
824
+ 'user.email': 'test@example.com',
539
825
  function_name: 'Bash',
540
826
  phase: 'execution',
541
827
  });
542
828
  expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 75, {
543
829
  'session.id': 'test-session-id',
830
+ 'installation.id': 'test-installation-id',
831
+ 'user.email': 'test@example.com',
544
832
  function_name: 'Bash',
545
833
  phase: 'result_processing',
546
834
  });
@@ -557,6 +845,8 @@ describe('Telemetry Metrics', () => {
557
845
  });
558
846
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.85, {
559
847
  'session.id': 'test-session-id',
848
+ 'installation.id': 'test-installation-id',
849
+ 'user.email': 'test@example.com',
560
850
  model: 'gemini-pro',
561
851
  metric: 'cache_hit_rate',
562
852
  context: 'api_request',
@@ -571,6 +861,8 @@ describe('Telemetry Metrics', () => {
571
861
  });
572
862
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(125.5, {
573
863
  'session.id': 'test-session-id',
864
+ 'installation.id': 'test-installation-id',
865
+ 'user.email': 'test@example.com',
574
866
  model: 'gemini-pro',
575
867
  metric: 'tokens_per_operation',
576
868
  });
@@ -586,6 +878,8 @@ describe('Telemetry Metrics', () => {
586
878
  });
587
879
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(15, {
588
880
  'session.id': 'test-session-id',
881
+ 'installation.id': 'test-installation-id',
882
+ 'user.email': 'test@example.com',
589
883
  model: 'gemini-pro',
590
884
  phase: 'request_preparation',
591
885
  });
@@ -608,16 +902,22 @@ describe('Telemetry Metrics', () => {
608
902
  expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
609
903
  expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 250, {
610
904
  'session.id': 'test-session-id',
905
+ 'installation.id': 'test-installation-id',
906
+ 'user.email': 'test@example.com',
611
907
  model: 'gemini-pro',
612
908
  phase: 'network_latency',
613
909
  });
614
910
  expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 100, {
615
911
  'session.id': 'test-session-id',
912
+ 'installation.id': 'test-installation-id',
913
+ 'user.email': 'test@example.com',
616
914
  model: 'gemini-pro',
617
915
  phase: 'response_processing',
618
916
  });
619
917
  expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 50, {
620
918
  'session.id': 'test-session-id',
919
+ 'installation.id': 'test-installation-id',
920
+ 'user.email': 'test@example.com',
621
921
  model: 'gemini-pro',
622
922
  phase: 'token_processing',
623
923
  });
@@ -633,6 +933,8 @@ describe('Telemetry Metrics', () => {
633
933
  });
634
934
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
635
935
  'session.id': 'test-session-id',
936
+ 'installation.id': 'test-installation-id',
937
+ 'user.email': 'test@example.com',
636
938
  category: 'memory_efficiency',
637
939
  baseline: 80.0,
638
940
  });
@@ -645,6 +947,8 @@ describe('Telemetry Metrics', () => {
645
947
  });
646
948
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(92.3, {
647
949
  'session.id': 'test-session-id',
950
+ 'installation.id': 'test-installation-id',
951
+ 'user.email': 'test@example.com',
648
952
  category: 'overall_performance',
649
953
  });
650
954
  });
@@ -663,6 +967,8 @@ describe('Telemetry Metrics', () => {
663
967
  // Verify regression counter
664
968
  expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
665
969
  'session.id': 'test-session-id',
970
+ 'installation.id': 'test-installation-id',
971
+ 'user.email': 'test@example.com',
666
972
  metric: 'startup_time',
667
973
  severity: 'medium',
668
974
  current_value: 1200,
@@ -671,6 +977,8 @@ describe('Telemetry Metrics', () => {
671
977
  // Verify baseline comparison histogram (20% increase)
672
978
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
673
979
  'session.id': 'test-session-id',
980
+ 'installation.id': 'test-installation-id',
981
+ 'user.email': 'test@example.com',
674
982
  metric: 'startup_time',
675
983
  severity: 'medium',
676
984
  current_value: 1200,
@@ -690,6 +998,8 @@ describe('Telemetry Metrics', () => {
690
998
  // Verify regression counter still recorded
691
999
  expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
692
1000
  'session.id': 'test-session-id',
1001
+ 'installation.id': 'test-installation-id',
1002
+ 'user.email': 'test@example.com',
693
1003
  metric: 'memory_usage',
694
1004
  severity: 'high',
695
1005
  current_value: 100,
@@ -715,6 +1025,8 @@ describe('Telemetry Metrics', () => {
715
1025
  });
716
1026
  expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
717
1027
  'session.id': 'test-session-id',
1028
+ 'installation.id': 'test-installation-id',
1029
+ 'user.email': 'test@example.com',
718
1030
  metric: 'api_latency',
719
1031
  severity: 'low',
720
1032
  current_value: 500,
@@ -722,6 +1034,8 @@ describe('Telemetry Metrics', () => {
722
1034
  });
723
1035
  expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
724
1036
  'session.id': 'test-session-id',
1037
+ 'installation.id': 'test-installation-id',
1038
+ 'user.email': 'test@example.com',
725
1039
  metric: 'cpu_usage',
726
1040
  severity: 'high',
727
1041
  current_value: 90,
@@ -742,6 +1056,8 @@ describe('Telemetry Metrics', () => {
742
1056
  // 20% increase: (120 - 100) / 100 * 100 = 20%
743
1057
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
744
1058
  'session.id': 'test-session-id',
1059
+ 'installation.id': 'test-installation-id',
1060
+ 'user.email': 'test@example.com',
745
1061
  metric: 'memory_usage',
746
1062
  category: 'performance_tracking',
747
1063
  current_value: 120,
@@ -760,6 +1076,8 @@ describe('Telemetry Metrics', () => {
760
1076
  // 20% decrease: (800 - 1000) / 1000 * 100 = -20%
761
1077
  expect(mockHistogramRecordFn).toHaveBeenCalledWith(-20, {
762
1078
  'session.id': 'test-session-id',
1079
+ 'installation.id': 'test-installation-id',
1080
+ 'user.email': 'test@example.com',
763
1081
  metric: 'startup_time',
764
1082
  category: 'optimization',
765
1083
  current_value: 800,