@google/gemini-cli-core 0.12.0-nightly.20251027.cb0947c5 → 0.13.0-nightly.20251030.42c79c64

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 (139) hide show
  1. package/README.md +7 -5
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/code_assist/oauth-credential-storage.js +5 -4
  6. package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
  7. package/dist/src/code_assist/oauth-credential-storage.test.js +15 -3
  8. package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -1
  9. package/dist/src/code_assist/oauth2.js +8 -9
  10. package/dist/src/code_assist/oauth2.js.map +1 -1
  11. package/dist/src/code_assist/oauth2.test.js +32 -32
  12. package/dist/src/code_assist/oauth2.test.js.map +1 -1
  13. package/dist/src/config/config.d.ts +11 -5
  14. package/dist/src/config/config.js +33 -10
  15. package/dist/src/config/config.js.map +1 -1
  16. package/dist/src/config/config.test.js +62 -15
  17. package/dist/src/config/config.test.js.map +1 -1
  18. package/dist/src/config/storage.d.ts +1 -0
  19. package/dist/src/config/storage.js +3 -0
  20. package/dist/src/config/storage.js.map +1 -1
  21. package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
  22. package/dist/src/core/apiKeyCredentialStorage.js +64 -0
  23. package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
  24. package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
  25. package/dist/src/core/apiKeyCredentialStorage.test.js +66 -0
  26. package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
  27. package/dist/src/core/contentGenerator.d.ts +1 -1
  28. package/dist/src/core/contentGenerator.js +41 -33
  29. package/dist/src/core/contentGenerator.js.map +1 -1
  30. package/dist/src/core/contentGenerator.test.js +24 -0
  31. package/dist/src/core/contentGenerator.test.js.map +1 -1
  32. package/dist/src/core/coreToolScheduler.js +109 -96
  33. package/dist/src/core/coreToolScheduler.js.map +1 -1
  34. package/dist/src/core/fakeContentGenerator.d.ts +20 -13
  35. package/dist/src/core/fakeContentGenerator.js +21 -24
  36. package/dist/src/core/fakeContentGenerator.js.map +1 -1
  37. package/dist/src/core/fakeContentGenerator.test.js +71 -84
  38. package/dist/src/core/fakeContentGenerator.test.js.map +1 -1
  39. package/dist/src/core/loggingContentGenerator.d.ts +1 -0
  40. package/dist/src/core/loggingContentGenerator.js +113 -33
  41. package/dist/src/core/loggingContentGenerator.js.map +1 -1
  42. package/dist/src/core/recordingContentGenerator.d.ts +18 -0
  43. package/dist/src/core/recordingContentGenerator.js +77 -0
  44. package/dist/src/core/recordingContentGenerator.js.map +1 -0
  45. package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
  46. package/dist/src/core/recordingContentGenerator.test.js +101 -0
  47. package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
  48. package/dist/src/fallback/handler.js +2 -0
  49. package/dist/src/fallback/handler.js.map +1 -1
  50. package/dist/src/generated/git-commit.d.ts +2 -2
  51. package/dist/src/generated/git-commit.js +2 -2
  52. package/dist/src/index.d.ts +4 -0
  53. package/dist/src/index.js +4 -0
  54. package/dist/src/index.js.map +1 -1
  55. package/dist/src/mcp/google-auth-provider.d.ts +0 -2
  56. package/dist/src/mcp/google-auth-provider.js +6 -40
  57. package/dist/src/mcp/google-auth-provider.js.map +1 -1
  58. package/dist/src/mcp/google-auth-provider.test.js +2 -63
  59. package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
  60. package/dist/src/mcp/sa-impersonation-provider.js +3 -2
  61. package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
  62. package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +6 -2
  63. package/dist/src/mcp/token-storage/keychain-token-storage.js +57 -2
  64. package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
  65. package/dist/src/mcp/token-storage/keychain-token-storage.test.js +33 -0
  66. package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -1
  67. package/dist/src/mcp/token-storage/types.d.ts +6 -0
  68. package/dist/src/mcp/token-storage/types.js.map +1 -1
  69. package/dist/src/policy/policy-engine.js +4 -0
  70. package/dist/src/policy/policy-engine.js.map +1 -1
  71. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +6 -5
  72. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  73. package/dist/src/telemetry/index.d.ts +1 -0
  74. package/dist/src/telemetry/index.js +1 -0
  75. package/dist/src/telemetry/index.js.map +1 -1
  76. package/dist/src/telemetry/loggers.js +10 -17
  77. package/dist/src/telemetry/loggers.js.map +1 -1
  78. package/dist/src/telemetry/loggers.test.js +182 -33
  79. package/dist/src/telemetry/loggers.test.js.map +1 -1
  80. package/dist/src/telemetry/metrics.d.ts +1 -1
  81. package/dist/src/telemetry/metrics.js +1 -1
  82. package/dist/src/telemetry/metrics.js.map +1 -1
  83. package/dist/src/telemetry/semantic.d.ts +82 -0
  84. package/dist/src/telemetry/semantic.js +269 -0
  85. package/dist/src/telemetry/semantic.js.map +1 -0
  86. package/dist/src/telemetry/semantic.test.d.ts +6 -0
  87. package/dist/src/telemetry/semantic.test.js +387 -0
  88. package/dist/src/telemetry/semantic.test.js.map +1 -0
  89. package/dist/src/telemetry/trace.d.ts +46 -0
  90. package/dist/src/telemetry/trace.js +121 -0
  91. package/dist/src/telemetry/trace.js.map +1 -0
  92. package/dist/src/telemetry/types.d.ts +39 -18
  93. package/dist/src/telemetry/types.js +113 -36
  94. package/dist/src/telemetry/types.js.map +1 -1
  95. package/dist/src/telemetry/uiTelemetry.js +6 -6
  96. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  97. package/dist/src/telemetry/uiTelemetry.test.js +88 -66
  98. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  99. package/dist/src/tools/glob.test.js +203 -199
  100. package/dist/src/tools/glob.test.js.map +1 -1
  101. package/dist/src/tools/mcp-client-manager.js +2 -1
  102. package/dist/src/tools/mcp-client-manager.js.map +1 -1
  103. package/dist/src/tools/mcp-client.d.ts +4 -1
  104. package/dist/src/tools/mcp-client.js +71 -92
  105. package/dist/src/tools/mcp-client.js.map +1 -1
  106. package/dist/src/tools/mcp-client.test.js +16 -6
  107. package/dist/src/tools/mcp-client.test.js.map +1 -1
  108. package/dist/src/tools/mcp-tool.d.ts +1 -1
  109. package/dist/src/tools/mcp-tool.js +11 -9
  110. package/dist/src/tools/mcp-tool.js.map +1 -1
  111. package/dist/src/tools/shell.d.ts +2 -2
  112. package/dist/src/tools/shell.js +8 -7
  113. package/dist/src/tools/shell.js.map +1 -1
  114. package/dist/src/tools/tool-registry.d.ts +3 -0
  115. package/dist/src/tools/tool-registry.js +9 -2
  116. package/dist/src/tools/tool-registry.js.map +1 -1
  117. package/dist/src/tools/tools.d.ts +1 -2
  118. package/dist/src/tools/tools.js +20 -3
  119. package/dist/src/tools/tools.js.map +1 -1
  120. package/dist/src/tools/write-todos.js +4 -1
  121. package/dist/src/tools/write-todos.js.map +1 -1
  122. package/dist/src/utils/events.d.ts +19 -1
  123. package/dist/src/utils/events.js +9 -0
  124. package/dist/src/utils/events.js.map +1 -1
  125. package/dist/src/utils/extensionLoader.d.ts +38 -0
  126. package/dist/src/utils/extensionLoader.js +20 -0
  127. package/dist/src/utils/extensionLoader.js.map +1 -0
  128. package/dist/src/utils/memoryDiscovery.d.ts +11 -2
  129. package/dist/src/utils/memoryDiscovery.js +140 -2
  130. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  131. package/dist/src/utils/memoryDiscovery.test.js +153 -37
  132. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  133. package/dist/src/utils/package.d.ts +12 -0
  134. package/dist/src/utils/package.js +15 -0
  135. package/dist/src/utils/package.js.map +1 -0
  136. package/dist/src/utils/workspaceContext.js +1 -1
  137. package/dist/src/utils/workspaceContext.js.map +1 -1
  138. package/dist/tsconfig.tsbuildinfo +1 -1
  139. package/package.json +2 -1
@@ -0,0 +1,387 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { describe, it, expect } from 'vitest';
7
+ import { toChatMessage, toInputMessages, toSystemInstruction, toOutputMessages, toFinishReasons, OTelFinishReason, toOutputType, OTelOutputType, } from './semantic.js';
8
+ import { Language, Outcome, FinishReason, } from '@google/genai';
9
+ describe('toChatMessage', () => {
10
+ it('should correctly handle text parts', () => {
11
+ const content = {
12
+ role: 'user',
13
+ parts: [{ text: 'Hello' }],
14
+ };
15
+ expect(toChatMessage(content)).toEqual({
16
+ role: 'user',
17
+ parts: [
18
+ {
19
+ type: 'text',
20
+ content: 'Hello',
21
+ },
22
+ ],
23
+ });
24
+ });
25
+ it('should correctly handle function call parts', () => {
26
+ const content = {
27
+ role: 'model',
28
+ parts: [
29
+ {
30
+ functionCall: {
31
+ name: 'test-function',
32
+ args: {
33
+ arg1: 'test-value',
34
+ },
35
+ id: '12345',
36
+ },
37
+ // include field not specified in semantic specification that could be present
38
+ thoughtSignature: '1234',
39
+ },
40
+ ],
41
+ };
42
+ expect(toChatMessage(content)).toEqual({
43
+ role: 'system',
44
+ parts: [
45
+ {
46
+ type: 'tool_call',
47
+ name: 'test-function',
48
+ arguments: '{"arg1":"test-value"}',
49
+ id: '12345',
50
+ },
51
+ ],
52
+ });
53
+ });
54
+ it('should correctly handle function response parts', () => {
55
+ const content = {
56
+ role: 'user',
57
+ parts: [
58
+ {
59
+ functionResponse: {
60
+ name: 'test-function',
61
+ response: {
62
+ result: 'success',
63
+ },
64
+ id: '12345',
65
+ },
66
+ // include field not specified in semantic specification that could be present
67
+ fileData: {
68
+ displayName: 'greatfile',
69
+ },
70
+ },
71
+ ],
72
+ };
73
+ expect(toChatMessage(content)).toEqual({
74
+ role: 'user',
75
+ parts: [
76
+ {
77
+ type: 'tool_call_response',
78
+ response: '{"result":"success"}',
79
+ id: '12345',
80
+ },
81
+ ],
82
+ });
83
+ });
84
+ it('should correctly handle reasoning parts with text', () => {
85
+ const content = {
86
+ role: 'system',
87
+ parts: [{ text: 'Hmm', thought: true }],
88
+ };
89
+ expect(toChatMessage(content)).toEqual({
90
+ role: 'system',
91
+ parts: [
92
+ {
93
+ type: 'reasoning',
94
+ content: 'Hmm',
95
+ },
96
+ ],
97
+ });
98
+ });
99
+ it('should correctly handle reasoning parts without text', () => {
100
+ const content = {
101
+ role: 'system',
102
+ parts: [
103
+ {
104
+ thought: true,
105
+ // include field not specified in semantic specification that could be present
106
+ inlineData: {
107
+ displayName: 'wowdata',
108
+ },
109
+ },
110
+ ],
111
+ };
112
+ expect(toChatMessage(content)).toEqual({
113
+ role: 'system',
114
+ parts: [
115
+ {
116
+ type: 'reasoning',
117
+ content: '',
118
+ },
119
+ ],
120
+ });
121
+ });
122
+ it('should correctly handle text parts that are not reasoning parts', () => {
123
+ const content = {
124
+ role: 'user',
125
+ parts: [{ text: 'what a nice day', thought: false }],
126
+ };
127
+ expect(toChatMessage(content)).toEqual({
128
+ role: 'user',
129
+ parts: [
130
+ {
131
+ type: 'text',
132
+ content: 'what a nice day',
133
+ },
134
+ ],
135
+ });
136
+ });
137
+ it('should correctly handle "generic" parts', () => {
138
+ const content = {
139
+ role: 'model',
140
+ parts: [
141
+ {
142
+ executableCode: {
143
+ code: 'print("foo")',
144
+ language: Language.PYTHON,
145
+ },
146
+ },
147
+ {
148
+ codeExecutionResult: {
149
+ outcome: Outcome.OUTCOME_OK,
150
+ output: 'foo',
151
+ },
152
+ // include field not specified in semantic specification that could be present
153
+ videoMetadata: {
154
+ fps: 5,
155
+ },
156
+ },
157
+ ],
158
+ };
159
+ expect(toChatMessage(content)).toEqual({
160
+ role: 'system',
161
+ parts: [
162
+ {
163
+ type: 'executableCode',
164
+ code: 'print("foo")',
165
+ language: 'PYTHON',
166
+ },
167
+ {
168
+ type: 'codeExecutionResult',
169
+ outcome: 'OUTCOME_OK',
170
+ output: 'foo',
171
+ videoMetadata: {
172
+ fps: 5,
173
+ },
174
+ },
175
+ ],
176
+ });
177
+ });
178
+ it('should correctly handle unknown parts', () => {
179
+ const content = {
180
+ role: 'model',
181
+ parts: [
182
+ {
183
+ fileData: {
184
+ displayName: 'superfile',
185
+ },
186
+ },
187
+ ],
188
+ };
189
+ expect(toChatMessage(content)).toEqual({
190
+ role: 'system',
191
+ parts: [
192
+ {
193
+ type: 'unknown',
194
+ fileData: {
195
+ displayName: 'superfile',
196
+ },
197
+ },
198
+ ],
199
+ });
200
+ });
201
+ });
202
+ describe('toSystemInstruction', () => {
203
+ it('should correctly handle a string', () => {
204
+ const content = 'Hello';
205
+ expect(toSystemInstruction(content)).toEqual([
206
+ {
207
+ type: 'text',
208
+ content: 'Hello',
209
+ },
210
+ ]);
211
+ });
212
+ it('should correctly handle a Content object with a text part', () => {
213
+ const content = {
214
+ role: 'user',
215
+ parts: [{ text: 'Hello' }],
216
+ };
217
+ expect(toSystemInstruction(content)).toEqual([
218
+ {
219
+ type: 'text',
220
+ content: 'Hello',
221
+ },
222
+ ]);
223
+ });
224
+ it('should correctly handle a Content object with multiple parts', () => {
225
+ const content = {
226
+ role: 'user',
227
+ parts: [{ text: 'Hello' }, { text: 'Hmm', thought: true }],
228
+ };
229
+ expect(toSystemInstruction(content)).toEqual([
230
+ {
231
+ type: 'text',
232
+ content: 'Hello',
233
+ },
234
+ {
235
+ type: 'reasoning',
236
+ content: 'Hmm',
237
+ },
238
+ ]);
239
+ });
240
+ });
241
+ describe('toInputMessages', () => {
242
+ it('should correctly convert an array of Content objects', () => {
243
+ const contents = [
244
+ {
245
+ role: 'user',
246
+ parts: [{ text: 'Hello' }],
247
+ },
248
+ {
249
+ role: 'model',
250
+ parts: [{ text: 'Hi there!' }],
251
+ },
252
+ ];
253
+ expect(toInputMessages(contents)).toEqual([
254
+ {
255
+ role: 'user',
256
+ parts: [
257
+ {
258
+ type: 'text',
259
+ content: 'Hello',
260
+ },
261
+ ],
262
+ },
263
+ {
264
+ role: 'system',
265
+ parts: [
266
+ {
267
+ type: 'text',
268
+ content: 'Hi there!',
269
+ },
270
+ ],
271
+ },
272
+ ]);
273
+ });
274
+ });
275
+ describe('toOutputMessages', () => {
276
+ it('should correctly convert an array of Candidate objects', () => {
277
+ const candidates = [
278
+ {
279
+ index: 0,
280
+ finishReason: FinishReason.STOP,
281
+ content: {
282
+ role: 'model',
283
+ parts: [{ text: 'This is the first candidate.' }],
284
+ },
285
+ },
286
+ {
287
+ index: 1,
288
+ finishReason: FinishReason.MAX_TOKENS,
289
+ content: {
290
+ role: 'model',
291
+ parts: [{ text: 'This is the second candidate.' }],
292
+ },
293
+ },
294
+ ];
295
+ expect(toOutputMessages(candidates)).toEqual([
296
+ {
297
+ role: 'system',
298
+ finish_reason: 'stop',
299
+ parts: [
300
+ {
301
+ type: 'text',
302
+ content: 'This is the first candidate.',
303
+ },
304
+ ],
305
+ },
306
+ {
307
+ role: 'system',
308
+ finish_reason: 'length',
309
+ parts: [
310
+ {
311
+ type: 'text',
312
+ content: 'This is the second candidate.',
313
+ },
314
+ ],
315
+ },
316
+ ]);
317
+ });
318
+ });
319
+ describe('toFinishReasons', () => {
320
+ it('should return an empty array if candidates is undefined', () => {
321
+ expect(toFinishReasons(undefined)).toEqual([]);
322
+ });
323
+ it('should return an empty array if candidates is an empty array', () => {
324
+ expect(toFinishReasons([])).toEqual([]);
325
+ });
326
+ it('should correctly convert a single candidate', () => {
327
+ const candidates = [
328
+ {
329
+ index: 0,
330
+ finishReason: FinishReason.STOP,
331
+ content: {
332
+ role: 'model',
333
+ parts: [{ text: 'This is the first candidate.' }],
334
+ },
335
+ },
336
+ ];
337
+ expect(toFinishReasons(candidates)).toEqual([OTelFinishReason.STOP]);
338
+ });
339
+ it('should correctly convert multiple candidates', () => {
340
+ const candidates = [
341
+ {
342
+ index: 0,
343
+ finishReason: FinishReason.STOP,
344
+ content: {
345
+ role: 'model',
346
+ parts: [{ text: 'This is the first candidate.' }],
347
+ },
348
+ },
349
+ {
350
+ index: 1,
351
+ finishReason: FinishReason.MAX_TOKENS,
352
+ content: {
353
+ role: 'model',
354
+ parts: [{ text: 'This is the second candidate.' }],
355
+ },
356
+ },
357
+ {
358
+ index: 2,
359
+ finishReason: FinishReason.SAFETY,
360
+ content: {
361
+ role: 'model',
362
+ parts: [{ text: 'This is the third candidate.' }],
363
+ },
364
+ },
365
+ ];
366
+ expect(toFinishReasons(candidates)).toEqual([
367
+ OTelFinishReason.STOP,
368
+ OTelFinishReason.LENGTH,
369
+ OTelFinishReason.CONTENT_FILTER,
370
+ ]);
371
+ });
372
+ });
373
+ describe('toOutputType', () => {
374
+ it('should return TEXT for text/plain', () => {
375
+ expect(toOutputType('text/plain')).toBe(OTelOutputType.TEXT);
376
+ });
377
+ it('should return JSON for application/json', () => {
378
+ expect(toOutputType('application/json')).toBe(OTelOutputType.JSON);
379
+ });
380
+ it('should return the custom mime type for other strings', () => {
381
+ expect(toOutputType('application/vnd.custom-type')).toBe('application/vnd.custom-type');
382
+ });
383
+ it('should return undefined for undefined input', () => {
384
+ expect(toOutputType(undefined)).toBeUndefined();
385
+ });
386
+ });
387
+ //# sourceMappingURL=semantic.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic.test.js","sourceRoot":"","sources":["../../../src/telemetry/semantic.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,QAAQ,EAER,OAAO,EAEP,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,OAAO,GAAY;YACvB,IAAI,EAAE,MAAM;YAC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,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,CAAC,YAAY,CAAC,6BAA6B,CAAC,CAAC,CAAC,IAAI,CACtD,6BAA6B,CAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { type AttributeValue, type SpanOptions } from '@opentelemetry/api';
7
+ /**
8
+ * Metadata for a span.
9
+ */
10
+ export interface SpanMetadata {
11
+ /** The name of the span. */
12
+ name: string;
13
+ /** The input to the span. */
14
+ input?: unknown;
15
+ /** The output of the span. */
16
+ output?: unknown;
17
+ error?: unknown;
18
+ /** Additional attributes for the span. */
19
+ attributes: Record<string, AttributeValue>;
20
+ }
21
+ /**
22
+ * Runs a function in a new OpenTelemetry span.
23
+ *
24
+ * The `meta` object will be automatically used to set the span's status and attributes upon completion.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * runInDevTraceSpan({ name: 'my-operation' }, ({ metadata }) => {
29
+ * metadata.input = { foo: 'bar' };
30
+ * // ... do work ...
31
+ * metadata.output = { result: 'baz' };
32
+ * metadata.attributes['my.custom.attribute'] = 'some-value';
33
+ * });
34
+ * ```
35
+ *
36
+ * @param opts The options for the span.
37
+ * @param fn The function to run in the span.
38
+ * @returns The result of the function.
39
+ */
40
+ export declare function runInDevTraceSpan<R>(opts: SpanOptions & {
41
+ name: string;
42
+ noAutoEnd?: boolean;
43
+ }, fn: ({ metadata, }: {
44
+ metadata: SpanMetadata;
45
+ endSpan: () => void;
46
+ }) => Promise<R>): Promise<R>;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { diag, SpanStatusCode, trace, } from '@opentelemetry/api';
7
+ import { safeJsonStringify } from '../utils/safeJsonStringify.js';
8
+ const TRACER_NAME = 'gemini-cli';
9
+ const TRACER_VERSION = 'v1';
10
+ /**
11
+ * Runs a function in a new OpenTelemetry span.
12
+ *
13
+ * The `meta` object will be automatically used to set the span's status and attributes upon completion.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * runInDevTraceSpan({ name: 'my-operation' }, ({ metadata }) => {
18
+ * metadata.input = { foo: 'bar' };
19
+ * // ... do work ...
20
+ * metadata.output = { result: 'baz' };
21
+ * metadata.attributes['my.custom.attribute'] = 'some-value';
22
+ * });
23
+ * ```
24
+ *
25
+ * @param opts The options for the span.
26
+ * @param fn The function to run in the span.
27
+ * @returns The result of the function.
28
+ */
29
+ export async function runInDevTraceSpan(opts, fn) {
30
+ const { name: spanName, noAutoEnd, ...restOfSpanOpts } = opts;
31
+ if (process.env['GEMINI_DEV_TRACING'] !== 'true') {
32
+ // If GEMINI_DEV_TRACING env var not set, we do not trace.
33
+ return await fn({
34
+ metadata: {
35
+ name: spanName,
36
+ attributes: {},
37
+ },
38
+ endSpan: () => {
39
+ // noop
40
+ },
41
+ });
42
+ }
43
+ const tracer = trace.getTracer(TRACER_NAME, TRACER_VERSION);
44
+ return await tracer.startActiveSpan(opts.name, restOfSpanOpts, async (span) => {
45
+ const meta = {
46
+ name: spanName,
47
+ attributes: {},
48
+ };
49
+ const endSpan = () => {
50
+ try {
51
+ if (meta.input !== undefined) {
52
+ span.setAttribute('input-json', safeJsonStringify(meta.input));
53
+ }
54
+ if (meta.output !== undefined) {
55
+ span.setAttribute('output-json', safeJsonStringify(meta.output));
56
+ }
57
+ for (const [key, value] of Object.entries(meta.attributes)) {
58
+ span.setAttribute(key, value);
59
+ }
60
+ if (meta.error) {
61
+ span.setStatus({
62
+ code: SpanStatusCode.ERROR,
63
+ message: getErrorMessage(meta.error),
64
+ });
65
+ if (meta.error instanceof Error) {
66
+ span.recordException(meta.error);
67
+ }
68
+ }
69
+ else {
70
+ span.setStatus({ code: SpanStatusCode.OK });
71
+ }
72
+ }
73
+ catch (e) {
74
+ // Log the error but don't rethrow, to ensure span.end() is called.
75
+ diag.error('Error setting span attributes in endSpan', e);
76
+ span.setStatus({
77
+ code: SpanStatusCode.ERROR,
78
+ message: `Error in endSpan: ${getErrorMessage(e)}`,
79
+ });
80
+ }
81
+ finally {
82
+ span.end();
83
+ }
84
+ };
85
+ try {
86
+ return await fn({ metadata: meta, endSpan });
87
+ }
88
+ catch (e) {
89
+ meta.error = e;
90
+ if (noAutoEnd) {
91
+ // For streaming operations, the delegated endSpan call will not be reached
92
+ // on an exception, so we must end the span here to prevent a leak.
93
+ endSpan();
94
+ }
95
+ throw e;
96
+ }
97
+ finally {
98
+ if (!noAutoEnd) {
99
+ // For non-streaming operations, this ensures the span is always closed,
100
+ // and if an error occurred, it will be recorded correctly by endSpan.
101
+ endSpan();
102
+ }
103
+ }
104
+ });
105
+ }
106
+ /**
107
+ * Gets the error message from an error object.
108
+ *
109
+ * @param e The error object.
110
+ * @returns The error message.
111
+ */
112
+ function getErrorMessage(e) {
113
+ if (e instanceof Error) {
114
+ return e.message;
115
+ }
116
+ if (typeof e === 'string') {
117
+ return e;
118
+ }
119
+ return safeJsonStringify(e);
120
+ }
121
+ //# sourceMappingURL=trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/telemetry/trace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,IAAI,EACJ,cAAc,EACd,KAAK,GAGN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,cAAc,GAAG,IAAI,CAAC;AAiB5B;;;;;;;;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EAAsE;gBACtE,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,CAAU;IACjC,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;QACvB,OAAO,CAAC,CAAC,OAAO,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC"}
@@ -3,13 +3,13 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { GenerateContentResponseUsageMetadata } from '@google/genai';
6
+ import type { Candidate, Content, GenerateContentConfig, GenerateContentResponseUsageMetadata } from '@google/genai';
7
7
  import type { Config } from '../config/config.js';
8
8
  import type { ApprovalMode } from '../config/config.js';
9
9
  import type { CompletedToolCall } from '../core/coreToolScheduler.js';
10
- import type { LogAttributes } from '@opentelemetry/api-logs';
10
+ import type { LogAttributes, LogRecord } from '@opentelemetry/api-logs';
11
11
  import { ToolCallDecision } from './tool-call-decision.js';
12
- import type { FileOperation } from './metrics.js';
12
+ import { type FileOperation } from './metrics.js';
13
13
  export { ToolCallDecision };
14
14
  import type { ToolRegistry } from '../tools/tool-registry.js';
15
15
  import type { OutputFormat } from '../output/types.js';
@@ -41,7 +41,9 @@ export declare class StartSessionEvent implements BaseTelemetryEvent {
41
41
  mcp_tools?: string;
42
42
  output_format: OutputFormat;
43
43
  extensions_count: number;
44
+ extensions: string;
44
45
  extension_ids: string;
46
+ auth_type?: string;
45
47
  constructor(config: Config, toolRegistry?: ToolRegistry);
46
48
  toOpenTelemetryAttributes(config: Config): LogAttributes;
47
49
  toLogBody(): string;
@@ -104,35 +106,54 @@ export declare class ApiErrorEvent implements BaseTelemetryEvent {
104
106
  'event.name': 'api_error';
105
107
  'event.timestamp': string;
106
108
  model: string;
109
+ prompt: GenAIPromptDetails;
107
110
  error: string;
108
111
  error_type?: string;
109
112
  status_code?: number | string;
110
113
  duration_ms: number;
111
- prompt_id: string;
112
114
  auth_type?: string;
113
- constructor(model: string, error: string, duration_ms: number, prompt_id: string, auth_type?: string, error_type?: string, status_code?: number | string);
114
- toOpenTelemetryAttributes(config: Config): LogAttributes;
115
- toLogBody(): string;
115
+ constructor(model: string, error: string, duration_ms: number, prompt_details: GenAIPromptDetails, auth_type?: string, error_type?: string, status_code?: number | string);
116
+ toLogRecord(config: Config): LogRecord;
117
+ toSemanticLogRecord(config: Config): LogRecord;
116
118
  }
117
- export declare const EVENT_API_RESPONSE = "gemini_cli.api_response";
118
- export declare class ApiResponseEvent implements BaseTelemetryEvent {
119
- 'event.name': 'api_response';
120
- 'event.timestamp': string;
121
- model: string;
122
- status_code?: number | string;
123
- duration_ms: number;
119
+ export interface ServerDetails {
120
+ address: string;
121
+ port: number;
122
+ }
123
+ export interface GenAIPromptDetails {
124
+ prompt_id: string;
125
+ contents: Content[];
126
+ generate_content_config?: GenerateContentConfig;
127
+ server?: ServerDetails;
128
+ }
129
+ export interface GenAIResponseDetails {
130
+ response_id?: string;
131
+ candidates?: Candidate[];
132
+ }
133
+ export interface GenAIUsageDetails {
124
134
  input_token_count: number;
125
135
  output_token_count: number;
126
136
  cached_content_token_count: number;
127
137
  thoughts_token_count: number;
128
138
  tool_token_count: number;
129
139
  total_token_count: number;
140
+ }
141
+ export declare const EVENT_API_RESPONSE = "gemini_cli.api_response";
142
+ export declare const EVENT_GEN_AI_OPERATION_DETAILS = "gen_ai.client.inference.operation.details";
143
+ export declare class ApiResponseEvent implements BaseTelemetryEvent {
144
+ 'event.name': 'api_response';
145
+ 'event.timestamp': string;
146
+ status_code?: number | string;
147
+ duration_ms: number;
130
148
  response_text?: string;
131
- prompt_id: string;
132
149
  auth_type?: string;
133
- constructor(model: string, duration_ms: number, prompt_id: string, auth_type?: string, usage_data?: GenerateContentResponseUsageMetadata, response_text?: string);
134
- toOpenTelemetryAttributes(config: Config): LogAttributes;
135
- toLogBody(): string;
150
+ model: string;
151
+ prompt: GenAIPromptDetails;
152
+ response: GenAIResponseDetails;
153
+ usage: GenAIUsageDetails;
154
+ constructor(model: string, duration_ms: number, prompt_details: GenAIPromptDetails, response_details: GenAIResponseDetails, auth_type?: string, usage_data?: GenerateContentResponseUsageMetadata, response_text?: string);
155
+ toLogRecord(config: Config): LogRecord;
156
+ toSemanticLogRecord(config: Config): LogRecord;
136
157
  }
137
158
  export declare const EVENT_FLASH_FALLBACK = "gemini_cli.flash_fallback";
138
159
  export declare class FlashFallbackEvent implements BaseTelemetryEvent {