@google/gemini-cli-core 0.10.0-nightly.20250926.1487841d → 0.10.0-nightly.20251009.cd354aeb

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 (246) hide show
  1. package/README.md +108 -71
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/agents/codebase-investigator.d.ts +46 -0
  6. package/dist/src/agents/codebase-investigator.js +136 -0
  7. package/dist/src/agents/codebase-investigator.js.map +1 -0
  8. package/dist/src/agents/executor.d.ts +92 -0
  9. package/dist/src/agents/executor.js +580 -0
  10. package/dist/src/agents/executor.js.map +1 -0
  11. package/dist/src/agents/executor.test.d.ts +6 -0
  12. package/dist/src/agents/executor.test.js +595 -0
  13. package/dist/src/agents/executor.test.js.map +1 -0
  14. package/dist/src/agents/invocation.d.ts +46 -0
  15. package/dist/src/agents/invocation.js +102 -0
  16. package/dist/src/agents/invocation.js.map +1 -0
  17. package/dist/src/agents/invocation.test.d.ts +6 -0
  18. package/dist/src/agents/invocation.test.js +215 -0
  19. package/dist/src/agents/invocation.test.js.map +1 -0
  20. package/dist/src/agents/registry.d.ts +36 -0
  21. package/dist/src/agents/registry.js +60 -0
  22. package/dist/src/agents/registry.js.map +1 -0
  23. package/dist/src/agents/registry.test.d.ts +6 -0
  24. package/dist/src/agents/registry.test.js +146 -0
  25. package/dist/src/agents/registry.test.js.map +1 -0
  26. package/dist/src/agents/schema-utils.d.ts +39 -0
  27. package/dist/src/agents/schema-utils.js +57 -0
  28. package/dist/src/agents/schema-utils.js.map +1 -0
  29. package/dist/src/agents/schema-utils.test.d.ts +6 -0
  30. package/dist/src/agents/schema-utils.test.js +144 -0
  31. package/dist/src/agents/schema-utils.test.js.map +1 -0
  32. package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
  33. package/dist/src/agents/subagent-tool-wrapper.js +48 -0
  34. package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
  35. package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
  36. package/dist/src/agents/subagent-tool-wrapper.test.js +112 -0
  37. package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
  38. package/dist/src/agents/types.d.ts +145 -0
  39. package/dist/src/agents/types.js +18 -0
  40. package/dist/src/agents/types.js.map +1 -0
  41. package/dist/src/agents/utils.d.ts +15 -0
  42. package/dist/src/agents/utils.js +29 -0
  43. package/dist/src/agents/utils.js.map +1 -0
  44. package/dist/src/agents/utils.test.d.ts +6 -0
  45. package/dist/src/agents/utils.test.js +87 -0
  46. package/dist/src/agents/utils.test.js.map +1 -0
  47. package/dist/src/code_assist/setup.js +4 -2
  48. package/dist/src/code_assist/setup.js.map +1 -1
  49. package/dist/src/config/config.d.ts +28 -5
  50. package/dist/src/config/config.js +61 -7
  51. package/dist/src/config/config.js.map +1 -1
  52. package/dist/src/config/config.test.js +63 -0
  53. package/dist/src/config/config.test.js.map +1 -1
  54. package/dist/src/core/baseLlmClient.js +19 -21
  55. package/dist/src/core/baseLlmClient.js.map +1 -1
  56. package/dist/src/core/baseLlmClient.test.js +57 -17
  57. package/dist/src/core/baseLlmClient.test.js.map +1 -1
  58. package/dist/src/core/client.d.ts +2 -0
  59. package/dist/src/core/client.js +52 -43
  60. package/dist/src/core/client.js.map +1 -1
  61. package/dist/src/core/client.test.js +300 -95
  62. package/dist/src/core/client.test.js.map +1 -1
  63. package/dist/src/core/contentGenerator.js +3 -1
  64. package/dist/src/core/contentGenerator.js.map +1 -1
  65. package/dist/src/core/coreToolScheduler.test.js +33 -23
  66. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  67. package/dist/src/core/geminiChat.d.ts +6 -0
  68. package/dist/src/core/geminiChat.js +21 -18
  69. package/dist/src/core/geminiChat.js.map +1 -1
  70. package/dist/src/core/geminiChat.test.js +20 -19
  71. package/dist/src/core/geminiChat.test.js.map +1 -1
  72. package/dist/src/core/nonInteractiveToolExecutor.test.js +11 -11
  73. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  74. package/dist/src/core/prompts.d.ts +2 -1
  75. package/dist/src/core/prompts.js +88 -15
  76. package/dist/src/core/prompts.js.map +1 -1
  77. package/dist/src/core/prompts.test.js +73 -24
  78. package/dist/src/core/prompts.test.js.map +1 -1
  79. package/dist/src/core/turn.d.ts +10 -2
  80. package/dist/src/core/turn.js +6 -1
  81. package/dist/src/core/turn.js.map +1 -1
  82. package/dist/src/core/turn.test.js +1 -1
  83. package/dist/src/core/turn.test.js.map +1 -1
  84. package/dist/src/generated/git-commit.d.ts +2 -2
  85. package/dist/src/generated/git-commit.js +2 -2
  86. package/dist/src/ide/detect-ide.d.ts +1 -0
  87. package/dist/src/ide/detect-ide.js +4 -1
  88. package/dist/src/ide/detect-ide.js.map +1 -1
  89. package/dist/src/ide/detect-ide.test.js +11 -0
  90. package/dist/src/ide/detect-ide.test.js.map +1 -1
  91. package/dist/src/ide/ide-client.js +3 -3
  92. package/dist/src/ide/ide-client.test.js +4 -4
  93. package/dist/src/ide/ide-installer.js +1 -1
  94. package/dist/src/ide/ide-installer.js.map +1 -1
  95. package/dist/src/ide/ide-installer.test.js +13 -1
  96. package/dist/src/ide/ide-installer.test.js.map +1 -1
  97. package/dist/src/index.d.ts +1 -0
  98. package/dist/src/index.js +1 -0
  99. package/dist/src/index.js.map +1 -1
  100. package/dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
  101. package/dist/src/mcp/sa-impersonation-provider.js +130 -0
  102. package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
  103. package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
  104. package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
  105. package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
  106. package/dist/src/services/chatRecordingService.d.ts +2 -1
  107. package/dist/src/services/chatRecordingService.js +2 -1
  108. package/dist/src/services/chatRecordingService.js.map +1 -1
  109. package/dist/src/services/fileSystemService.d.ts +9 -0
  110. package/dist/src/services/fileSystemService.js +11 -0
  111. package/dist/src/services/fileSystemService.js.map +1 -1
  112. package/dist/src/services/shellExecutionService.d.ts +2 -0
  113. package/dist/src/services/shellExecutionService.js +48 -7
  114. package/dist/src/services/shellExecutionService.js.map +1 -1
  115. package/dist/src/services/shellExecutionService.test.js +13 -4
  116. package/dist/src/services/shellExecutionService.test.js.map +1 -1
  117. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +12 -2
  118. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +79 -9
  119. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  120. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +99 -1
  121. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  122. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +11 -3
  123. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +27 -4
  124. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  125. package/dist/src/telemetry/constants.d.ts +6 -24
  126. package/dist/src/telemetry/constants.js +7 -25
  127. package/dist/src/telemetry/constants.js.map +1 -1
  128. package/dist/src/telemetry/index.d.ts +5 -3
  129. package/dist/src/telemetry/index.js +10 -3
  130. package/dist/src/telemetry/index.js.map +1 -1
  131. package/dist/src/telemetry/loggers.d.ts +6 -1
  132. package/dist/src/telemetry/loggers.js +132 -12
  133. package/dist/src/telemetry/loggers.js.map +1 -1
  134. package/dist/src/telemetry/loggers.test.circular.js +3 -3
  135. package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
  136. package/dist/src/telemetry/loggers.test.js +160 -13
  137. package/dist/src/telemetry/loggers.test.js.map +1 -1
  138. package/dist/src/telemetry/memory-monitor.d.ts +149 -0
  139. package/dist/src/telemetry/memory-monitor.js +335 -0
  140. package/dist/src/telemetry/memory-monitor.js.map +1 -0
  141. package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
  142. package/dist/src/telemetry/memory-monitor.test.js +472 -0
  143. package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
  144. package/dist/src/telemetry/metrics.d.ts +392 -20
  145. package/dist/src/telemetry/metrics.js +463 -235
  146. package/dist/src/telemetry/metrics.js.map +1 -1
  147. package/dist/src/telemetry/metrics.test.js +391 -55
  148. package/dist/src/telemetry/metrics.test.js.map +1 -1
  149. package/dist/src/telemetry/types.d.ts +37 -1
  150. package/dist/src/telemetry/types.js +60 -0
  151. package/dist/src/telemetry/types.js.map +1 -1
  152. package/dist/src/telemetry/uiTelemetry.test.js +2 -2
  153. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  154. package/dist/src/test-utils/mock-tool.d.ts +28 -3
  155. package/dist/src/test-utils/mock-tool.js +71 -1
  156. package/dist/src/test-utils/mock-tool.js.map +1 -1
  157. package/dist/src/tools/glob.js +2 -1
  158. package/dist/src/tools/glob.js.map +1 -1
  159. package/dist/src/tools/mcp-client.d.ts +3 -2
  160. package/dist/src/tools/mcp-client.js +44 -30
  161. package/dist/src/tools/mcp-client.js.map +1 -1
  162. package/dist/src/tools/mcp-client.test.js +168 -5
  163. package/dist/src/tools/mcp-client.test.js.map +1 -1
  164. package/dist/src/tools/shell.js +2 -2
  165. package/dist/src/tools/shell.js.map +1 -1
  166. package/dist/src/tools/shell.test.js +1 -1
  167. package/dist/src/tools/shell.test.js.map +1 -1
  168. package/dist/src/tools/smart-edit.d.ts +20 -1
  169. package/dist/src/tools/smart-edit.js +149 -9
  170. package/dist/src/tools/smart-edit.js.map +1 -1
  171. package/dist/src/tools/smart-edit.test.js +150 -29
  172. package/dist/src/tools/smart-edit.test.js.map +1 -1
  173. package/dist/src/tools/tool-names.d.ts +8 -0
  174. package/dist/src/tools/tool-names.js +17 -0
  175. package/dist/src/tools/tool-names.js.map +1 -0
  176. package/dist/src/tools/tool-registry.test.js +10 -10
  177. package/dist/src/tools/tool-registry.test.js.map +1 -1
  178. package/dist/src/tools/web-fetch.js +3 -0
  179. package/dist/src/tools/web-fetch.js.map +1 -1
  180. package/dist/src/tools/web-fetch.test.js +44 -0
  181. package/dist/src/tools/web-fetch.test.js.map +1 -1
  182. package/dist/src/tools/write-file.js +2 -1
  183. package/dist/src/tools/write-file.js.map +1 -1
  184. package/dist/src/tools/write-todos.d.ts +1 -1
  185. package/dist/src/tools/write-todos.js +4 -3
  186. package/dist/src/tools/write-todos.js.map +1 -1
  187. package/dist/src/utils/editCorrector.js +2 -2
  188. package/dist/src/utils/editCorrector.js.map +1 -1
  189. package/dist/src/utils/editor.js +1 -0
  190. package/dist/src/utils/editor.js.map +1 -1
  191. package/dist/src/utils/editor.test.js +1 -0
  192. package/dist/src/utils/editor.test.js.map +1 -1
  193. package/dist/src/utils/errorParsing.d.ts +1 -1
  194. package/dist/src/utils/errorParsing.js +5 -33
  195. package/dist/src/utils/errorParsing.js.map +1 -1
  196. package/dist/src/utils/errorParsing.test.js +0 -88
  197. package/dist/src/utils/errorParsing.test.js.map +1 -1
  198. package/dist/src/utils/flashFallback.test.js +26 -45
  199. package/dist/src/utils/flashFallback.test.js.map +1 -1
  200. package/dist/src/utils/formatters.d.ts +1 -0
  201. package/dist/src/utils/formatters.js +2 -1
  202. package/dist/src/utils/formatters.js.map +1 -1
  203. package/dist/src/utils/formatters.test.d.ts +6 -0
  204. package/dist/src/utils/formatters.test.js +26 -0
  205. package/dist/src/utils/formatters.test.js.map +1 -0
  206. package/dist/src/utils/googleErrors.d.ts +104 -0
  207. package/dist/src/utils/googleErrors.js +108 -0
  208. package/dist/src/utils/googleErrors.js.map +1 -0
  209. package/dist/src/utils/googleErrors.test.d.ts +6 -0
  210. package/dist/src/utils/googleErrors.test.js +212 -0
  211. package/dist/src/utils/googleErrors.test.js.map +1 -0
  212. package/dist/src/utils/googleQuotaErrors.d.ts +35 -0
  213. package/dist/src/utils/googleQuotaErrors.js +108 -0
  214. package/dist/src/utils/googleQuotaErrors.js.map +1 -0
  215. package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
  216. package/dist/src/utils/googleQuotaErrors.test.js +189 -0
  217. package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
  218. package/dist/src/utils/llm-edit-fixer.js +13 -4
  219. package/dist/src/utils/llm-edit-fixer.js.map +1 -1
  220. package/dist/src/utils/llm-edit-fixer.test.js +81 -0
  221. package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
  222. package/dist/src/utils/memoryDiscovery.d.ts +1 -0
  223. package/dist/src/utils/memoryDiscovery.js +2 -1
  224. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  225. package/dist/src/utils/memoryDiscovery.test.js +99 -21
  226. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  227. package/dist/src/utils/memoryImportProcessor.js +13 -20
  228. package/dist/src/utils/memoryImportProcessor.js.map +1 -1
  229. package/dist/src/utils/memoryImportProcessor.test.js +14 -0
  230. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
  231. package/dist/src/utils/quotaErrorDetection.d.ts +0 -2
  232. package/dist/src/utils/quotaErrorDetection.js +0 -46
  233. package/dist/src/utils/quotaErrorDetection.js.map +1 -1
  234. package/dist/src/utils/retry.d.ts +3 -1
  235. package/dist/src/utils/retry.js +53 -161
  236. package/dist/src/utils/retry.js.map +1 -1
  237. package/dist/src/utils/retry.test.js +87 -146
  238. package/dist/src/utils/retry.test.js.map +1 -1
  239. package/dist/src/utils/terminalSerializer.d.ts +1 -4
  240. package/dist/src/utils/terminalSerializer.js +3 -3
  241. package/dist/src/utils/terminalSerializer.js.map +1 -1
  242. package/dist/tsconfig.tsbuildinfo +1 -1
  243. package/package.json +1 -1
  244. package/dist/src/test-utils/tools.d.ts +0 -45
  245. package/dist/src/test-utils/tools.js +0 -105
  246. package/dist/src/test-utils/tools.js.map +0 -1
@@ -3,9 +3,329 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { Meter } from '@opentelemetry/api';
6
+ import type { Attributes, Meter, Counter, Histogram } from '@opentelemetry/api';
7
+ import { ValueType } from '@opentelemetry/api';
8
+ import { EVENT_CHAT_COMPRESSION } from './constants.js';
7
9
  import type { Config } from '../config/config.js';
8
- import type { ModelRoutingEvent, ModelSlashCommandEvent } from './types.js';
10
+ import type { ModelRoutingEvent, ModelSlashCommandEvent, AgentFinishEvent } from './types.js';
11
+ declare const TOOL_CALL_COUNT = "gemini_cli.tool.call.count";
12
+ declare const API_REQUEST_COUNT = "gemini_cli.api.request.count";
13
+ declare const TOKEN_USAGE = "gemini_cli.token.usage";
14
+ declare const FILE_OPERATION_COUNT = "gemini_cli.file.operation.count";
15
+ declare const GEN_AI_CLIENT_TOKEN_USAGE = "gen_ai.client.token.usage";
16
+ declare const GEN_AI_CLIENT_OPERATION_DURATION = "gen_ai.client.operation.duration";
17
+ declare const STARTUP_TIME = "gemini_cli.startup.duration";
18
+ declare const MEMORY_USAGE = "gemini_cli.memory.usage";
19
+ declare const CPU_USAGE = "gemini_cli.cpu.usage";
20
+ declare const TOOL_EXECUTION_BREAKDOWN = "gemini_cli.tool.execution.breakdown";
21
+ declare const TOKEN_EFFICIENCY = "gemini_cli.token.efficiency";
22
+ declare const API_REQUEST_BREAKDOWN = "gemini_cli.api.request.breakdown";
23
+ declare const PERFORMANCE_SCORE = "gemini_cli.performance.score";
24
+ declare const REGRESSION_DETECTION = "gemini_cli.performance.regression";
25
+ declare const BASELINE_COMPARISON = "gemini_cli.performance.baseline.comparison";
26
+ declare const COUNTER_DEFINITIONS: {
27
+ readonly "gemini_cli.tool.call.count": {
28
+ readonly description: "Counts tool calls, tagged by function name and success.";
29
+ readonly valueType: ValueType.INT;
30
+ readonly assign: (c: Counter) => Counter<Attributes>;
31
+ readonly attributes: {
32
+ function_name: string;
33
+ success: boolean;
34
+ decision?: "accept" | "reject" | "modify" | "auto_accept";
35
+ tool_type?: "native" | "mcp";
36
+ };
37
+ };
38
+ readonly "gemini_cli.api.request.count": {
39
+ readonly description: "Counts API requests, tagged by model and status.";
40
+ readonly valueType: ValueType.INT;
41
+ readonly assign: (c: Counter) => Counter<Attributes>;
42
+ readonly attributes: {
43
+ model: string;
44
+ status_code?: number | string;
45
+ error_type?: string;
46
+ };
47
+ };
48
+ readonly "gemini_cli.token.usage": {
49
+ readonly description: "Counts the total number of tokens used.";
50
+ readonly valueType: ValueType.INT;
51
+ readonly assign: (c: Counter) => Counter<Attributes>;
52
+ readonly attributes: {
53
+ model: string;
54
+ type: "input" | "output" | "thought" | "cache" | "tool";
55
+ };
56
+ };
57
+ readonly "gemini_cli.session.count": {
58
+ readonly description: "Count of CLI sessions started.";
59
+ readonly valueType: ValueType.INT;
60
+ readonly assign: (c: Counter) => Counter<Attributes>;
61
+ readonly attributes: Record<string, never>;
62
+ };
63
+ readonly "gemini_cli.file.operation.count": {
64
+ readonly description: "Counts file operations (create, read, update).";
65
+ readonly valueType: ValueType.INT;
66
+ readonly assign: (c: Counter) => Counter<Attributes>;
67
+ readonly attributes: {
68
+ operation: FileOperation;
69
+ lines?: number;
70
+ mimetype?: string;
71
+ extension?: string;
72
+ programming_language?: string;
73
+ };
74
+ };
75
+ readonly "gemini_cli.chat.invalid_chunk.count": {
76
+ readonly description: "Counts invalid chunks received from a stream.";
77
+ readonly valueType: ValueType.INT;
78
+ readonly assign: (c: Counter) => Counter<Attributes>;
79
+ readonly attributes: Record<string, never>;
80
+ };
81
+ readonly "gemini_cli.chat.content_retry.count": {
82
+ readonly description: "Counts retries due to content errors (e.g., empty stream).";
83
+ readonly valueType: ValueType.INT;
84
+ readonly assign: (c: Counter) => Counter<Attributes>;
85
+ readonly attributes: Record<string, never>;
86
+ };
87
+ readonly "gemini_cli.chat.content_retry_failure.count": {
88
+ readonly description: "Counts occurrences of all content retries failing.";
89
+ readonly valueType: ValueType.INT;
90
+ readonly assign: (c: Counter) => Counter<Attributes>;
91
+ readonly attributes: Record<string, never>;
92
+ };
93
+ readonly "gemini_cli.model_routing.failure.count": {
94
+ readonly description: "Counts model routing failures.";
95
+ readonly valueType: ValueType.INT;
96
+ readonly assign: (c: Counter) => Counter<Attributes>;
97
+ readonly attributes: {
98
+ "routing.decision_source": string;
99
+ "routing.error_message": string;
100
+ };
101
+ };
102
+ readonly "gemini_cli.slash_command.model.call_count": {
103
+ readonly description: "Counts model slash command calls.";
104
+ readonly valueType: ValueType.INT;
105
+ readonly assign: (c: Counter) => Counter<Attributes>;
106
+ readonly attributes: {
107
+ "slash_command.model.model_name": string;
108
+ };
109
+ };
110
+ readonly "gemini_cli.chat_compression": {
111
+ readonly description: "Counts chat compression events.";
112
+ readonly valueType: ValueType.INT;
113
+ readonly assign: (c: Counter) => Counter<Attributes>;
114
+ readonly attributes: {
115
+ tokens_before: number;
116
+ tokens_after: number;
117
+ };
118
+ };
119
+ readonly "gemini_cli.agent.run.count": {
120
+ readonly description: "Counts agent runs, tagged by name and termination reason.";
121
+ readonly valueType: ValueType.INT;
122
+ readonly assign: (c: Counter) => Counter<Attributes>;
123
+ readonly attributes: {
124
+ agent_name: string;
125
+ terminate_reason: string;
126
+ };
127
+ };
128
+ };
129
+ declare const HISTOGRAM_DEFINITIONS: {
130
+ readonly "gemini_cli.tool.call.latency": {
131
+ readonly description: "Latency of tool calls in milliseconds.";
132
+ readonly unit: "ms";
133
+ readonly valueType: ValueType.INT;
134
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
135
+ readonly attributes: {
136
+ function_name: string;
137
+ };
138
+ };
139
+ readonly "gemini_cli.api.request.latency": {
140
+ readonly description: "Latency of API requests in milliseconds.";
141
+ readonly unit: "ms";
142
+ readonly valueType: ValueType.INT;
143
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
144
+ readonly attributes: {
145
+ model: string;
146
+ };
147
+ };
148
+ readonly "gemini_cli.model_routing.latency": {
149
+ readonly description: "Latency of model routing decisions in milliseconds.";
150
+ readonly unit: "ms";
151
+ readonly valueType: ValueType.INT;
152
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
153
+ readonly attributes: {
154
+ "routing.decision_model": string;
155
+ "routing.decision_source": string;
156
+ };
157
+ };
158
+ readonly "gemini_cli.agent.duration": {
159
+ readonly description: "Duration of agent runs in milliseconds.";
160
+ readonly unit: "ms";
161
+ readonly valueType: ValueType.INT;
162
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
163
+ readonly attributes: {
164
+ agent_name: string;
165
+ };
166
+ };
167
+ readonly "gemini_cli.agent.turns": {
168
+ readonly description: "Number of turns taken by agents.";
169
+ readonly unit: "turns";
170
+ readonly valueType: ValueType.INT;
171
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
172
+ readonly attributes: {
173
+ agent_name: string;
174
+ };
175
+ };
176
+ readonly "gen_ai.client.token.usage": {
177
+ readonly description: "Number of input and output tokens used.";
178
+ readonly unit: "token";
179
+ readonly valueType: ValueType.INT;
180
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
181
+ readonly attributes: {
182
+ "gen_ai.operation.name": string;
183
+ "gen_ai.provider.name": string;
184
+ "gen_ai.token.type": "input" | "output";
185
+ "gen_ai.request.model"?: string;
186
+ "gen_ai.response.model"?: string;
187
+ "server.address"?: string;
188
+ "server.port"?: number;
189
+ };
190
+ };
191
+ readonly "gen_ai.client.operation.duration": {
192
+ readonly description: "GenAI operation duration.";
193
+ readonly unit: "s";
194
+ readonly valueType: ValueType.DOUBLE;
195
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
196
+ readonly attributes: {
197
+ "gen_ai.operation.name": string;
198
+ "gen_ai.provider.name": string;
199
+ "gen_ai.request.model"?: string;
200
+ "gen_ai.response.model"?: string;
201
+ "server.address"?: string;
202
+ "server.port"?: number;
203
+ "error.type"?: string;
204
+ };
205
+ };
206
+ };
207
+ declare const PERFORMANCE_COUNTER_DEFINITIONS: {
208
+ readonly "gemini_cli.performance.regression": {
209
+ readonly description: "Performance regression detection events.";
210
+ readonly valueType: ValueType.INT;
211
+ readonly assign: (c: Counter) => Counter<Attributes>;
212
+ readonly attributes: {
213
+ metric: string;
214
+ severity: "low" | "medium" | "high";
215
+ current_value: number;
216
+ baseline_value: number;
217
+ };
218
+ };
219
+ };
220
+ declare const PERFORMANCE_HISTOGRAM_DEFINITIONS: {
221
+ readonly "gemini_cli.startup.duration": {
222
+ readonly description: "CLI startup time in milliseconds, broken down by initialization phase.";
223
+ readonly unit: "ms";
224
+ readonly valueType: ValueType.DOUBLE;
225
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
226
+ readonly attributes: {
227
+ phase: string;
228
+ details?: Record<string, string | number | boolean>;
229
+ };
230
+ };
231
+ readonly "gemini_cli.memory.usage": {
232
+ readonly description: "Memory usage in bytes.";
233
+ readonly unit: "bytes";
234
+ readonly valueType: ValueType.INT;
235
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
236
+ readonly attributes: {
237
+ memory_type: MemoryMetricType;
238
+ component?: string;
239
+ };
240
+ };
241
+ readonly "gemini_cli.cpu.usage": {
242
+ readonly description: "CPU usage percentage.";
243
+ readonly unit: "percent";
244
+ readonly valueType: ValueType.DOUBLE;
245
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
246
+ readonly attributes: {
247
+ component?: string;
248
+ };
249
+ };
250
+ readonly "gemini_cli.tool.queue.depth": {
251
+ readonly description: "Number of tools in execution queue.";
252
+ readonly unit: "count";
253
+ readonly valueType: ValueType.INT;
254
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
255
+ readonly attributes: Record<string, never>;
256
+ };
257
+ readonly "gemini_cli.tool.execution.breakdown": {
258
+ readonly description: "Tool execution time breakdown by phase in milliseconds.";
259
+ readonly unit: "ms";
260
+ readonly valueType: ValueType.INT;
261
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
262
+ readonly attributes: {
263
+ function_name: string;
264
+ phase: ToolExecutionPhase;
265
+ };
266
+ };
267
+ readonly "gemini_cli.token.efficiency": {
268
+ readonly description: "Token efficiency metrics (tokens per operation, cache hit rate, etc.).";
269
+ readonly unit: "ratio";
270
+ readonly valueType: ValueType.DOUBLE;
271
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
272
+ readonly attributes: {
273
+ model: string;
274
+ metric: string;
275
+ context?: string;
276
+ };
277
+ };
278
+ readonly "gemini_cli.api.request.breakdown": {
279
+ readonly description: "API request time breakdown by phase in milliseconds.";
280
+ readonly unit: "ms";
281
+ readonly valueType: ValueType.INT;
282
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
283
+ readonly attributes: {
284
+ model: string;
285
+ phase: ApiRequestPhase;
286
+ };
287
+ };
288
+ readonly "gemini_cli.performance.score": {
289
+ readonly description: "Composite performance score (0-100).";
290
+ readonly unit: "score";
291
+ readonly valueType: ValueType.DOUBLE;
292
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
293
+ readonly attributes: {
294
+ category: string;
295
+ baseline?: number;
296
+ };
297
+ };
298
+ readonly "gemini_cli.performance.regression.percentage_change": {
299
+ readonly description: "Percentage change compared to baseline for detected regressions.";
300
+ readonly unit: "percent";
301
+ readonly valueType: ValueType.DOUBLE;
302
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
303
+ readonly attributes: {
304
+ metric: string;
305
+ severity: "low" | "medium" | "high";
306
+ current_value: number;
307
+ baseline_value: number;
308
+ };
309
+ };
310
+ readonly "gemini_cli.performance.baseline.comparison": {
311
+ readonly description: "Performance comparison to established baseline (percentage change).";
312
+ readonly unit: "percent";
313
+ readonly valueType: ValueType.DOUBLE;
314
+ readonly assign: (h: Histogram) => Histogram<Attributes>;
315
+ readonly attributes: {
316
+ metric: string;
317
+ category: string;
318
+ current_value: number;
319
+ baseline_value: number;
320
+ };
321
+ };
322
+ };
323
+ type AllMetricDefs = typeof COUNTER_DEFINITIONS & typeof HISTOGRAM_DEFINITIONS & typeof PERFORMANCE_COUNTER_DEFINITIONS & typeof PERFORMANCE_HISTOGRAM_DEFINITIONS;
324
+ export type MetricDefinitions = {
325
+ [K in keyof AllMetricDefs]: {
326
+ attributes: AllMetricDefs[K]['attributes'];
327
+ };
328
+ };
9
329
  export declare enum FileOperation {
10
330
  CREATE = "create",
11
331
  READ = "read",
@@ -37,17 +357,25 @@ export declare enum ApiRequestPhase {
37
357
  RESPONSE_PROCESSING = "response_processing",
38
358
  TOKEN_PROCESSING = "token_processing"
39
359
  }
360
+ export declare enum GenAiOperationName {
361
+ GENERATE_CONTENT = "generate_content"
362
+ }
363
+ export declare enum GenAiProviderName {
364
+ GCP_GEN_AI = "gcp.gen_ai",
365
+ GCP_VERTEX_AI = "gcp.vertex_ai"
366
+ }
367
+ export declare enum GenAiTokenType {
368
+ INPUT = "input",
369
+ OUTPUT = "output"
370
+ }
40
371
  export declare function getMeter(): Meter | undefined;
41
372
  export declare function initializeMetrics(config: Config): void;
42
- export declare function recordChatCompressionMetrics(config: Config, args: {
43
- tokens_before: number;
44
- tokens_after: number;
45
- }): void;
46
- export declare function recordToolCallMetrics(config: Config, functionName: string, durationMs: number, success: boolean, decision?: 'accept' | 'reject' | 'modify' | 'auto_accept', tool_type?: 'native' | 'mcp'): void;
47
- export declare function recordTokenUsageMetrics(config: Config, model: string, tokenCount: number, type: 'input' | 'output' | 'thought' | 'cache' | 'tool'): void;
48
- export declare function recordApiResponseMetrics(config: Config, model: string, durationMs: number, statusCode?: number | string): void;
49
- export declare function recordApiErrorMetrics(config: Config, model: string, durationMs: number, statusCode?: number | string, errorType?: string): void;
50
- export declare function recordFileOperationMetric(config: Config, operation: FileOperation, lines?: number, mimetype?: string, extension?: string, programming_language?: string): void;
373
+ export declare function recordChatCompressionMetrics(config: Config, attributes: MetricDefinitions[typeof EVENT_CHAT_COMPRESSION]['attributes']): void;
374
+ export declare function recordToolCallMetrics(config: Config, durationMs: number, attributes: MetricDefinitions[typeof TOOL_CALL_COUNT]['attributes']): void;
375
+ export declare function recordCustomTokenUsageMetrics(config: Config, tokenCount: number, attributes: MetricDefinitions[typeof TOKEN_USAGE]['attributes']): void;
376
+ export declare function recordCustomApiResponseMetrics(config: Config, durationMs: number, attributes: MetricDefinitions[typeof API_REQUEST_COUNT]['attributes']): void;
377
+ export declare function recordApiErrorMetrics(config: Config, durationMs: number, attributes: MetricDefinitions[typeof API_REQUEST_COUNT]['attributes']): void;
378
+ export declare function recordFileOperationMetric(config: Config, attributes: MetricDefinitions[typeof FILE_OPERATION_COUNT]['attributes']): void;
51
379
  /**
52
380
  * Records a metric for when an invalid chunk is received from a stream.
53
381
  */
@@ -62,15 +390,59 @@ export declare function recordContentRetry(config: Config): void;
62
390
  export declare function recordContentRetryFailure(config: Config): void;
63
391
  export declare function recordModelSlashCommand(config: Config, event: ModelSlashCommandEvent): void;
64
392
  export declare function recordModelRoutingMetrics(config: Config, event: ModelRoutingEvent): void;
393
+ export declare function recordAgentRunMetrics(config: Config, event: AgentFinishEvent): void;
394
+ export declare function recordGenAiClientTokenUsage(config: Config, tokenCount: number, attributes: MetricDefinitions[typeof GEN_AI_CLIENT_TOKEN_USAGE]['attributes']): void;
395
+ export declare function recordGenAiClientOperationDuration(config: Config, durationSeconds: number, attributes: MetricDefinitions[typeof GEN_AI_CLIENT_OPERATION_DURATION]['attributes']): void;
396
+ export declare function getConventionAttributes(event: {
397
+ model: string;
398
+ auth_type?: string;
399
+ }): {
400
+ 'gen_ai.operation.name': GenAiOperationName;
401
+ 'gen_ai.provider.name': GenAiProviderName;
402
+ 'gen_ai.request.model': string;
403
+ 'gen_ai.response.model': string;
404
+ };
65
405
  export declare function initializePerformanceMonitoring(config: Config): void;
66
- export declare function recordStartupPerformance(config: Config, phase: string, durationMs: number, details?: Record<string, string | number | boolean>): void;
67
- export declare function recordMemoryUsage(config: Config, memoryType: MemoryMetricType, bytes: number, component?: string): void;
68
- export declare function recordCpuUsage(config: Config, percentage: number, component?: string): void;
406
+ export declare function recordStartupPerformance(config: Config, durationMs: number, attributes: MetricDefinitions[typeof STARTUP_TIME]['attributes']): void;
407
+ export declare function recordMemoryUsage(config: Config, bytes: number, attributes: MetricDefinitions[typeof MEMORY_USAGE]['attributes']): void;
408
+ export declare function recordCpuUsage(config: Config, percentage: number, attributes: MetricDefinitions[typeof CPU_USAGE]['attributes']): void;
69
409
  export declare function recordToolQueueDepth(config: Config, queueDepth: number): void;
70
- export declare function recordToolExecutionBreakdown(config: Config, functionName: string, phase: ToolExecutionPhase, durationMs: number): void;
71
- export declare function recordTokenEfficiency(config: Config, model: string, metric: string, value: number, context?: string): void;
72
- export declare function recordApiRequestBreakdown(config: Config, model: string, phase: ApiRequestPhase, durationMs: number): void;
73
- export declare function recordPerformanceScore(config: Config, score: number, category: string, baseline?: number): void;
74
- export declare function recordPerformanceRegression(config: Config, metric: string, currentValue: number, baselineValue: number, severity: 'low' | 'medium' | 'high'): void;
75
- export declare function recordBaselineComparison(config: Config, metric: string, currentValue: number, baselineValue: number, category: string): void;
410
+ export declare function recordToolExecutionBreakdown(config: Config, durationMs: number, attributes: MetricDefinitions[typeof TOOL_EXECUTION_BREAKDOWN]['attributes']): void;
411
+ export declare function recordTokenEfficiency(config: Config, value: number, attributes: MetricDefinitions[typeof TOKEN_EFFICIENCY]['attributes']): void;
412
+ export declare function recordApiRequestBreakdown(config: Config, durationMs: number, attributes: MetricDefinitions[typeof API_REQUEST_BREAKDOWN]['attributes']): void;
413
+ export declare function recordPerformanceScore(config: Config, score: number, attributes: MetricDefinitions[typeof PERFORMANCE_SCORE]['attributes']): void;
414
+ export declare function recordPerformanceRegression(config: Config, attributes: MetricDefinitions[typeof REGRESSION_DETECTION]['attributes']): void;
415
+ export declare function recordBaselineComparison(config: Config, attributes: MetricDefinitions[typeof BASELINE_COMPARISON]['attributes']): void;
76
416
  export declare function isPerformanceMonitoringActive(): boolean;
417
+ /**
418
+ * Token usage recording that emits both custom and convention metrics.
419
+ */
420
+ export declare function recordTokenUsageMetrics(config: Config, tokenCount: number, attributes: {
421
+ model: string;
422
+ type: 'input' | 'output' | 'thought' | 'cache' | 'tool';
423
+ genAiAttributes?: {
424
+ 'gen_ai.operation.name': string;
425
+ 'gen_ai.provider.name': string;
426
+ 'gen_ai.request.model'?: string;
427
+ 'gen_ai.response.model'?: string;
428
+ 'server.address'?: string;
429
+ 'server.port'?: number;
430
+ };
431
+ }): void;
432
+ /**
433
+ * Operation latency recording that emits both custom and convention metrics.
434
+ */
435
+ export declare function recordApiResponseMetrics(config: Config, durationMs: number, attributes: {
436
+ model: string;
437
+ status_code?: number | string;
438
+ genAiAttributes?: {
439
+ 'gen_ai.operation.name': string;
440
+ 'gen_ai.provider.name': string;
441
+ 'gen_ai.request.model'?: string;
442
+ 'gen_ai.response.model'?: string;
443
+ 'server.address'?: string;
444
+ 'server.port'?: number;
445
+ 'error.type'?: string;
446
+ };
447
+ }): void;
448
+ export {};