@google/gemini-cli-core 0.0.77777772 → 0.0.77777773
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.
- package/README.md +108 -71
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +46 -0
- package/dist/src/agents/codebase-investigator.js +136 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/executor.d.ts +92 -0
- package/dist/src/agents/executor.js +579 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.d.ts +6 -0
- package/dist/src/agents/executor.test.js +595 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +46 -0
- package/dist/src/agents/invocation.js +102 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.d.ts +6 -0
- package/dist/src/agents/invocation.test.js +215 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +36 -0
- package/dist/src/agents/registry.js +60 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +146 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +112 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +145 -0
- package/dist/src/agents/types.js +18 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +1 -1
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +14 -13
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +4 -2
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/config/config.d.ts +37 -11
- package/dist/src/config/config.js +77 -18
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +88 -3
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +0 -1
- package/dist/src/config/storage.js +2 -2
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +7 -6
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/core/baseLlmClient.js +19 -21
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +57 -17
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +3 -1
- package/dist/src/core/client.js +68 -46
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +385 -95
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.js +3 -1
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +12 -12
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +260 -23
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +7 -11
- package/dist/src/core/geminiChat.js +31 -74
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +60 -229
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/logger.test.js +2 -2
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +11 -11
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +2 -1
- package/dist/src/core/prompts.js +91 -17
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +78 -29
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +14 -2
- package/dist/src/core/turn.js +12 -1
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +14 -2
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/ide/detect-ide.d.ts +1 -0
- package/dist/src/ide/detect-ide.js +4 -1
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +11 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +3 -3
- package/dist/src/ide/ide-client.test.js +4 -4
- package/dist/src/ide/ide-installer.js +1 -1
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +13 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
- package/dist/src/mcp/sa-impersonation-provider.js +130 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +2 -1
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.test.js +4 -3
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +2 -1
- package/dist/src/services/chatRecordingService.js +2 -1
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +11 -0
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +3 -0
- package/dist/src/services/shellExecutionService.js +165 -49
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +74 -5
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +14 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +119 -12
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +99 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +13 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +32 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -52
- package/dist/src/telemetry/constants.js +0 -54
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +5 -3
- package/dist/src/telemetry/index.js +11 -4
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +8 -2
- package/dist/src/telemetry/loggers.js +187 -288
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -3
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +232 -13
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +406 -20
- package/dist/src/telemetry/metrics.js +479 -235
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +551 -55
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +18 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +150 -3
- package/dist/src/telemetry/types.js +664 -33
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
- package/dist/src/telemetry/uiTelemetry.js +1 -1
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +3 -3
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +28 -3
- package/dist/src/test-utils/mock-tool.js +71 -1
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/glob.js +2 -1
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +3 -2
- package/dist/src/tools/mcp-client.js +45 -33
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +168 -5
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +1 -1
- package/dist/src/tools/memoryTool.js +1 -2
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +9 -8
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/shell.js +2 -2
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +1 -1
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +1 -1
- package/dist/src/tools/smart-edit.js +114 -10
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +91 -29
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +21 -0
- package/dist/src/tools/tool-error.js +27 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +9 -0
- package/dist/src/tools/tool-names.js +18 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.test.js +10 -10
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/web-fetch.js +3 -0
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +44 -0
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.js +2 -1
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.js +2 -1
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +1 -1
- package/dist/src/tools/write-todos.js +4 -3
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/utils/editCorrector.js +2 -2
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editor.js +1 -0
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +1 -0
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -1
- package/dist/src/utils/errorParsing.js +5 -33
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +0 -88
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +26 -45
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.test.js +7 -6
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +108 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +6 -0
- package/dist/src/utils/googleErrors.test.js +212 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +35 -0
- package/dist/src/utils/googleQuotaErrors.js +108 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
- package/dist/src/utils/googleQuotaErrors.test.js +189 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/installationManager.test.js +2 -1
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +13 -4
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +81 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +1 -0
- package/dist/src/utils/memoryDiscovery.js +2 -1
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +99 -21
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +13 -20
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +14 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +0 -2
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +3 -1
- package/dist/src/utils/retry.js +53 -161
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +90 -149
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +1 -4
- package/dist/src/utils/terminalSerializer.js +3 -3
- package/dist/src/utils/terminalSerializer.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +2 -1
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/test-utils/tools.d.ts +0 -45
- package/dist/src/test-utils/tools.js +0 -105
- package/dist/src/test-utils/tools.js.map +0 -1
|
@@ -7,6 +7,10 @@ import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
|
|
|
7
7
|
import { AuthType } from '../core/contentGenerator.js';
|
|
8
8
|
import { getDecisionFromOutcome, ToolCallDecision, } from './tool-call-decision.js';
|
|
9
9
|
export { ToolCallDecision };
|
|
10
|
+
import { getCommonAttributes } from './telemetryAttributes.js';
|
|
11
|
+
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
|
|
12
|
+
import { safeJsonStringify } from '../utils/safeJsonStringify.js';
|
|
13
|
+
export const EVENT_CLI_CONFIG = 'gemini_cli.config';
|
|
10
14
|
export class StartSessionEvent {
|
|
11
15
|
'event.name';
|
|
12
16
|
'event.timestamp';
|
|
@@ -36,6 +40,7 @@ export class StartSessionEvent {
|
|
|
36
40
|
useVertex = generatorConfig.authType === AuthType.USE_VERTEX_AI;
|
|
37
41
|
}
|
|
38
42
|
this['event.name'] = 'cli_config';
|
|
43
|
+
this['event.timestamp'] = new Date().toISOString();
|
|
39
44
|
this.model = config.getModel();
|
|
40
45
|
this.embedding_model = config.getEmbeddingModel();
|
|
41
46
|
this.sandbox_enabled =
|
|
@@ -63,6 +68,31 @@ export class StartSessionEvent {
|
|
|
63
68
|
.join(',');
|
|
64
69
|
}
|
|
65
70
|
}
|
|
71
|
+
toOpenTelemetryAttributes(config) {
|
|
72
|
+
return {
|
|
73
|
+
...getCommonAttributes(config),
|
|
74
|
+
'event.name': EVENT_CLI_CONFIG,
|
|
75
|
+
'event.timestamp': this['event.timestamp'],
|
|
76
|
+
model: this.model,
|
|
77
|
+
embedding_model: this.embedding_model,
|
|
78
|
+
sandbox_enabled: this.sandbox_enabled,
|
|
79
|
+
core_tools_enabled: this.core_tools_enabled,
|
|
80
|
+
approval_mode: this.approval_mode,
|
|
81
|
+
api_key_enabled: this.api_key_enabled,
|
|
82
|
+
vertex_ai_enabled: this.vertex_ai_enabled,
|
|
83
|
+
log_user_prompts_enabled: this.telemetry_log_user_prompts_enabled,
|
|
84
|
+
file_filtering_respect_git_ignore: this.file_filtering_respect_git_ignore,
|
|
85
|
+
debug_mode: this.debug_enabled,
|
|
86
|
+
mcp_servers: this.mcp_servers,
|
|
87
|
+
mcp_servers_count: this.mcp_servers_count,
|
|
88
|
+
mcp_tools: this.mcp_tools,
|
|
89
|
+
mcp_tools_count: this.mcp_tools_count,
|
|
90
|
+
output_format: this.output_format,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
toLogBody() {
|
|
94
|
+
return 'CLI configuration loaded.';
|
|
95
|
+
}
|
|
66
96
|
}
|
|
67
97
|
export class EndSessionEvent {
|
|
68
98
|
'event.name';
|
|
@@ -74,6 +104,7 @@ export class EndSessionEvent {
|
|
|
74
104
|
this.session_id = config?.getSessionId();
|
|
75
105
|
}
|
|
76
106
|
}
|
|
107
|
+
export const EVENT_USER_PROMPT = 'gemini_cli.user_prompt';
|
|
77
108
|
export class UserPromptEvent {
|
|
78
109
|
'event.name';
|
|
79
110
|
'event.timestamp';
|
|
@@ -89,7 +120,27 @@ export class UserPromptEvent {
|
|
|
89
120
|
this.auth_type = auth_type;
|
|
90
121
|
this.prompt = prompt;
|
|
91
122
|
}
|
|
123
|
+
toOpenTelemetryAttributes(config) {
|
|
124
|
+
const attributes = {
|
|
125
|
+
...getCommonAttributes(config),
|
|
126
|
+
'event.name': EVENT_USER_PROMPT,
|
|
127
|
+
'event.timestamp': this['event.timestamp'],
|
|
128
|
+
prompt_length: this.prompt_length,
|
|
129
|
+
prompt_id: this.prompt_id,
|
|
130
|
+
};
|
|
131
|
+
if (this.auth_type) {
|
|
132
|
+
attributes['auth_type'] = this.auth_type;
|
|
133
|
+
}
|
|
134
|
+
if (config.getTelemetryLogPromptsEnabled()) {
|
|
135
|
+
attributes['prompt'] = this.prompt;
|
|
136
|
+
}
|
|
137
|
+
return attributes;
|
|
138
|
+
}
|
|
139
|
+
toLogBody() {
|
|
140
|
+
return `User prompt. Length: ${this.prompt_length}.`;
|
|
141
|
+
}
|
|
92
142
|
}
|
|
143
|
+
export const EVENT_TOOL_CALL = 'gemini_cli.tool_call';
|
|
93
144
|
export class ToolCallEvent {
|
|
94
145
|
'event.name';
|
|
95
146
|
'event.timestamp';
|
|
@@ -106,48 +157,89 @@ export class ToolCallEvent {
|
|
|
106
157
|
mcp_server_name;
|
|
107
158
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
159
|
metadata;
|
|
109
|
-
constructor(call) {
|
|
160
|
+
constructor(call, function_name, function_args, duration_ms, success, prompt_id, tool_type, error) {
|
|
110
161
|
this['event.name'] = 'tool_call';
|
|
111
162
|
this['event.timestamp'] = new Date().toISOString();
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
call.tool
|
|
125
|
-
|
|
126
|
-
|
|
163
|
+
if (call) {
|
|
164
|
+
this.function_name = call.request.name;
|
|
165
|
+
this.function_args = call.request.args;
|
|
166
|
+
this.duration_ms = call.durationMs ?? 0;
|
|
167
|
+
this.success = call.status === 'success';
|
|
168
|
+
this.decision = call.outcome
|
|
169
|
+
? getDecisionFromOutcome(call.outcome)
|
|
170
|
+
: undefined;
|
|
171
|
+
this.error = call.response.error?.message;
|
|
172
|
+
this.error_type = call.response.errorType;
|
|
173
|
+
this.prompt_id = call.request.prompt_id;
|
|
174
|
+
this.content_length = call.response.contentLength;
|
|
175
|
+
if (typeof call.tool !== 'undefined' &&
|
|
176
|
+
call.tool instanceof DiscoveredMCPTool) {
|
|
177
|
+
this.tool_type = 'mcp';
|
|
178
|
+
this.mcp_server_name = call.tool.serverName;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.tool_type = 'native';
|
|
182
|
+
}
|
|
183
|
+
if (call.status === 'success' &&
|
|
184
|
+
typeof call.response.resultDisplay === 'object' &&
|
|
185
|
+
call.response.resultDisplay !== null &&
|
|
186
|
+
'diffStat' in call.response.resultDisplay) {
|
|
187
|
+
const diffStat = call.response.resultDisplay.diffStat;
|
|
188
|
+
if (diffStat) {
|
|
189
|
+
this.metadata = {
|
|
190
|
+
model_added_lines: diffStat.model_added_lines,
|
|
191
|
+
model_removed_lines: diffStat.model_removed_lines,
|
|
192
|
+
model_added_chars: diffStat.model_added_chars,
|
|
193
|
+
model_removed_chars: diffStat.model_removed_chars,
|
|
194
|
+
user_added_lines: diffStat.user_added_lines,
|
|
195
|
+
user_removed_lines: diffStat.user_removed_lines,
|
|
196
|
+
user_added_chars: diffStat.user_added_chars,
|
|
197
|
+
user_removed_chars: diffStat.user_removed_chars,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
127
201
|
}
|
|
128
202
|
else {
|
|
129
|
-
this.
|
|
203
|
+
this.function_name = function_name;
|
|
204
|
+
this.function_args = function_args;
|
|
205
|
+
this.duration_ms = duration_ms;
|
|
206
|
+
this.success = success;
|
|
207
|
+
this.prompt_id = prompt_id;
|
|
208
|
+
this.tool_type = tool_type;
|
|
209
|
+
this.error = error;
|
|
130
210
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
211
|
+
}
|
|
212
|
+
toOpenTelemetryAttributes(config) {
|
|
213
|
+
const attributes = {
|
|
214
|
+
...getCommonAttributes(config),
|
|
215
|
+
'event.name': EVENT_TOOL_CALL,
|
|
216
|
+
'event.timestamp': this['event.timestamp'],
|
|
217
|
+
function_name: this.function_name,
|
|
218
|
+
function_args: safeJsonStringify(this.function_args, 2),
|
|
219
|
+
duration_ms: this.duration_ms,
|
|
220
|
+
success: this.success,
|
|
221
|
+
decision: this.decision,
|
|
222
|
+
prompt_id: this.prompt_id,
|
|
223
|
+
tool_type: this.tool_type,
|
|
224
|
+
content_length: this.content_length,
|
|
225
|
+
mcp_server_name: this.mcp_server_name,
|
|
226
|
+
metadata: this.metadata,
|
|
227
|
+
};
|
|
228
|
+
if (this.error) {
|
|
229
|
+
attributes['error'] = this.error;
|
|
230
|
+
attributes['error.message'] = this.error;
|
|
231
|
+
if (this.error_type) {
|
|
232
|
+
attributes['error_type'] = this.error_type;
|
|
233
|
+
attributes['error.type'] = this.error_type;
|
|
147
234
|
}
|
|
148
235
|
}
|
|
236
|
+
return attributes;
|
|
237
|
+
}
|
|
238
|
+
toLogBody() {
|
|
239
|
+
return `Tool call: ${this.function_name}${this.decision ? `. Decision: ${this.decision}` : ''}. Success: ${this.success}. Duration: ${this.duration_ms}ms.`;
|
|
149
240
|
}
|
|
150
241
|
}
|
|
242
|
+
export const EVENT_API_REQUEST = 'gemini_cli.api_request';
|
|
151
243
|
export class ApiRequestEvent {
|
|
152
244
|
'event.name';
|
|
153
245
|
'event.timestamp';
|
|
@@ -161,7 +253,21 @@ export class ApiRequestEvent {
|
|
|
161
253
|
this.prompt_id = prompt_id;
|
|
162
254
|
this.request_text = request_text;
|
|
163
255
|
}
|
|
256
|
+
toOpenTelemetryAttributes(config) {
|
|
257
|
+
return {
|
|
258
|
+
...getCommonAttributes(config),
|
|
259
|
+
'event.name': EVENT_API_REQUEST,
|
|
260
|
+
'event.timestamp': this['event.timestamp'],
|
|
261
|
+
model: this.model,
|
|
262
|
+
prompt_id: this.prompt_id,
|
|
263
|
+
request_text: this.request_text,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
toLogBody() {
|
|
267
|
+
return `API request to ${this.model}.`;
|
|
268
|
+
}
|
|
164
269
|
}
|
|
270
|
+
export const EVENT_API_ERROR = 'gemini_cli.api_error';
|
|
165
271
|
export class ApiErrorEvent {
|
|
166
272
|
'event.name';
|
|
167
273
|
'event.timestamp';
|
|
@@ -183,7 +289,34 @@ export class ApiErrorEvent {
|
|
|
183
289
|
this.prompt_id = prompt_id;
|
|
184
290
|
this.auth_type = auth_type;
|
|
185
291
|
}
|
|
292
|
+
toOpenTelemetryAttributes(config) {
|
|
293
|
+
const attributes = {
|
|
294
|
+
...getCommonAttributes(config),
|
|
295
|
+
'event.name': EVENT_API_ERROR,
|
|
296
|
+
'event.timestamp': this['event.timestamp'],
|
|
297
|
+
['error.message']: this.error,
|
|
298
|
+
model_name: this.model,
|
|
299
|
+
duration: this.duration_ms,
|
|
300
|
+
model: this.model,
|
|
301
|
+
error: this.error,
|
|
302
|
+
status_code: this.status_code,
|
|
303
|
+
duration_ms: this.duration_ms,
|
|
304
|
+
prompt_id: this.prompt_id,
|
|
305
|
+
auth_type: this.auth_type,
|
|
306
|
+
};
|
|
307
|
+
if (this.error_type) {
|
|
308
|
+
attributes['error.type'] = this.error_type;
|
|
309
|
+
}
|
|
310
|
+
if (typeof this.status_code === 'number') {
|
|
311
|
+
attributes[SemanticAttributes.HTTP_STATUS_CODE] = this.status_code;
|
|
312
|
+
}
|
|
313
|
+
return attributes;
|
|
314
|
+
}
|
|
315
|
+
toLogBody() {
|
|
316
|
+
return `API error for ${this.model}. Error: ${this.error}. Duration: ${this.duration_ms}ms.`;
|
|
317
|
+
}
|
|
186
318
|
}
|
|
319
|
+
export const EVENT_API_RESPONSE = 'gemini_cli.api_response';
|
|
187
320
|
export class ApiResponseEvent {
|
|
188
321
|
'event.name';
|
|
189
322
|
'event.timestamp';
|
|
@@ -215,7 +348,38 @@ export class ApiResponseEvent {
|
|
|
215
348
|
this.prompt_id = prompt_id;
|
|
216
349
|
this.auth_type = auth_type;
|
|
217
350
|
}
|
|
351
|
+
toOpenTelemetryAttributes(config) {
|
|
352
|
+
const attributes = {
|
|
353
|
+
...getCommonAttributes(config),
|
|
354
|
+
'event.name': EVENT_API_RESPONSE,
|
|
355
|
+
'event.timestamp': this['event.timestamp'],
|
|
356
|
+
model: this.model,
|
|
357
|
+
duration_ms: this.duration_ms,
|
|
358
|
+
input_token_count: this.input_token_count,
|
|
359
|
+
output_token_count: this.output_token_count,
|
|
360
|
+
cached_content_token_count: this.cached_content_token_count,
|
|
361
|
+
thoughts_token_count: this.thoughts_token_count,
|
|
362
|
+
tool_token_count: this.tool_token_count,
|
|
363
|
+
total_token_count: this.total_token_count,
|
|
364
|
+
prompt_id: this.prompt_id,
|
|
365
|
+
auth_type: this.auth_type,
|
|
366
|
+
status_code: this.status_code,
|
|
367
|
+
};
|
|
368
|
+
if (this.response_text) {
|
|
369
|
+
attributes['response_text'] = this.response_text;
|
|
370
|
+
}
|
|
371
|
+
if (this.status_code) {
|
|
372
|
+
if (typeof this.status_code === 'number') {
|
|
373
|
+
attributes[SemanticAttributes.HTTP_STATUS_CODE] = this.status_code;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return attributes;
|
|
377
|
+
}
|
|
378
|
+
toLogBody() {
|
|
379
|
+
return `API response from ${this.model}. Status: ${this.status_code || 'N/A'}. Duration: ${this.duration_ms}ms.`;
|
|
380
|
+
}
|
|
218
381
|
}
|
|
382
|
+
export const EVENT_FLASH_FALLBACK = 'gemini_cli.flash_fallback';
|
|
219
383
|
export class FlashFallbackEvent {
|
|
220
384
|
'event.name';
|
|
221
385
|
'event.timestamp';
|
|
@@ -225,7 +389,19 @@ export class FlashFallbackEvent {
|
|
|
225
389
|
this['event.timestamp'] = new Date().toISOString();
|
|
226
390
|
this.auth_type = auth_type;
|
|
227
391
|
}
|
|
392
|
+
toOpenTelemetryAttributes(config) {
|
|
393
|
+
return {
|
|
394
|
+
...getCommonAttributes(config),
|
|
395
|
+
'event.name': EVENT_FLASH_FALLBACK,
|
|
396
|
+
'event.timestamp': this['event.timestamp'],
|
|
397
|
+
auth_type: this.auth_type,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
toLogBody() {
|
|
401
|
+
return `Switching to flash as Fallback.`;
|
|
402
|
+
}
|
|
228
403
|
}
|
|
404
|
+
export const EVENT_RIPGREP_FALLBACK = 'gemini_cli.ripgrep_fallback';
|
|
229
405
|
export class RipgrepFallbackEvent {
|
|
230
406
|
error;
|
|
231
407
|
'event.name';
|
|
@@ -235,6 +411,17 @@ export class RipgrepFallbackEvent {
|
|
|
235
411
|
this['event.name'] = 'ripgrep_fallback';
|
|
236
412
|
this['event.timestamp'] = new Date().toISOString();
|
|
237
413
|
}
|
|
414
|
+
toOpenTelemetryAttributes(config) {
|
|
415
|
+
return {
|
|
416
|
+
...getCommonAttributes(config),
|
|
417
|
+
'event.name': EVENT_RIPGREP_FALLBACK,
|
|
418
|
+
'event.timestamp': this['event.timestamp'],
|
|
419
|
+
error: this.error,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
toLogBody() {
|
|
423
|
+
return `Switching to grep as fallback.`;
|
|
424
|
+
}
|
|
238
425
|
}
|
|
239
426
|
export var LoopType;
|
|
240
427
|
(function (LoopType) {
|
|
@@ -253,6 +440,18 @@ export class LoopDetectedEvent {
|
|
|
253
440
|
this.loop_type = loop_type;
|
|
254
441
|
this.prompt_id = prompt_id;
|
|
255
442
|
}
|
|
443
|
+
toOpenTelemetryAttributes(config) {
|
|
444
|
+
return {
|
|
445
|
+
...getCommonAttributes(config),
|
|
446
|
+
'event.name': this['event.name'],
|
|
447
|
+
'event.timestamp': this['event.timestamp'],
|
|
448
|
+
loop_type: this.loop_type,
|
|
449
|
+
prompt_id: this.prompt_id,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
toLogBody() {
|
|
453
|
+
return `Loop detected. Type: ${this.loop_type}.`;
|
|
454
|
+
}
|
|
256
455
|
}
|
|
257
456
|
export class LoopDetectionDisabledEvent {
|
|
258
457
|
'event.name';
|
|
@@ -263,7 +462,19 @@ export class LoopDetectionDisabledEvent {
|
|
|
263
462
|
this['event.timestamp'] = new Date().toISOString();
|
|
264
463
|
this.prompt_id = prompt_id;
|
|
265
464
|
}
|
|
465
|
+
toOpenTelemetryAttributes(config) {
|
|
466
|
+
return {
|
|
467
|
+
...getCommonAttributes(config),
|
|
468
|
+
'event.name': this['event.name'],
|
|
469
|
+
'event.timestamp': this['event.timestamp'],
|
|
470
|
+
prompt_id: this.prompt_id,
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
toLogBody() {
|
|
474
|
+
return `Loop detection disabled.`;
|
|
475
|
+
}
|
|
266
476
|
}
|
|
477
|
+
export const EVENT_NEXT_SPEAKER_CHECK = 'gemini_cli.next_speaker_check';
|
|
267
478
|
export class NextSpeakerCheckEvent {
|
|
268
479
|
'event.name';
|
|
269
480
|
'event.timestamp';
|
|
@@ -277,7 +488,21 @@ export class NextSpeakerCheckEvent {
|
|
|
277
488
|
this.finish_reason = finish_reason;
|
|
278
489
|
this.result = result;
|
|
279
490
|
}
|
|
491
|
+
toOpenTelemetryAttributes(config) {
|
|
492
|
+
return {
|
|
493
|
+
...getCommonAttributes(config),
|
|
494
|
+
'event.name': EVENT_NEXT_SPEAKER_CHECK,
|
|
495
|
+
'event.timestamp': this['event.timestamp'],
|
|
496
|
+
prompt_id: this.prompt_id,
|
|
497
|
+
finish_reason: this.finish_reason,
|
|
498
|
+
result: this.result,
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
toLogBody() {
|
|
502
|
+
return `Next speaker check.`;
|
|
503
|
+
}
|
|
280
504
|
}
|
|
505
|
+
export const EVENT_SLASH_COMMAND = 'gemini_cli.slash_command';
|
|
281
506
|
export function makeSlashCommandEvent({ command, subcommand, status, }) {
|
|
282
507
|
return {
|
|
283
508
|
'event.name': 'slash_command',
|
|
@@ -285,6 +510,19 @@ export function makeSlashCommandEvent({ command, subcommand, status, }) {
|
|
|
285
510
|
command,
|
|
286
511
|
subcommand,
|
|
287
512
|
status,
|
|
513
|
+
toOpenTelemetryAttributes(config) {
|
|
514
|
+
return {
|
|
515
|
+
...getCommonAttributes(config),
|
|
516
|
+
'event.name': EVENT_SLASH_COMMAND,
|
|
517
|
+
'event.timestamp': this['event.timestamp'],
|
|
518
|
+
command: this.command,
|
|
519
|
+
subcommand: this.subcommand,
|
|
520
|
+
status: this.status,
|
|
521
|
+
};
|
|
522
|
+
},
|
|
523
|
+
toLogBody() {
|
|
524
|
+
return `Slash command: ${this.command}.`;
|
|
525
|
+
},
|
|
288
526
|
};
|
|
289
527
|
}
|
|
290
528
|
export var SlashCommandStatus;
|
|
@@ -292,14 +530,28 @@ export var SlashCommandStatus;
|
|
|
292
530
|
SlashCommandStatus["SUCCESS"] = "success";
|
|
293
531
|
SlashCommandStatus["ERROR"] = "error";
|
|
294
532
|
})(SlashCommandStatus || (SlashCommandStatus = {}));
|
|
533
|
+
export const EVENT_CHAT_COMPRESSION = 'gemini_cli.chat_compression';
|
|
295
534
|
export function makeChatCompressionEvent({ tokens_before, tokens_after, }) {
|
|
296
535
|
return {
|
|
297
536
|
'event.name': 'chat_compression',
|
|
298
537
|
'event.timestamp': new Date().toISOString(),
|
|
299
538
|
tokens_before,
|
|
300
539
|
tokens_after,
|
|
540
|
+
toOpenTelemetryAttributes(config) {
|
|
541
|
+
return {
|
|
542
|
+
...getCommonAttributes(config),
|
|
543
|
+
'event.name': EVENT_CHAT_COMPRESSION,
|
|
544
|
+
'event.timestamp': this['event.timestamp'],
|
|
545
|
+
tokens_before: this.tokens_before,
|
|
546
|
+
tokens_after: this.tokens_after,
|
|
547
|
+
};
|
|
548
|
+
},
|
|
549
|
+
toLogBody() {
|
|
550
|
+
return `Chat compression (Saved ${this.tokens_before - this.tokens_after} tokens)`;
|
|
551
|
+
},
|
|
301
552
|
};
|
|
302
553
|
}
|
|
554
|
+
export const EVENT_MALFORMED_JSON_RESPONSE = 'gemini_cli.malformed_json_response';
|
|
303
555
|
export class MalformedJsonResponseEvent {
|
|
304
556
|
'event.name';
|
|
305
557
|
'event.timestamp';
|
|
@@ -309,12 +561,24 @@ export class MalformedJsonResponseEvent {
|
|
|
309
561
|
this['event.timestamp'] = new Date().toISOString();
|
|
310
562
|
this.model = model;
|
|
311
563
|
}
|
|
564
|
+
toOpenTelemetryAttributes(config) {
|
|
565
|
+
return {
|
|
566
|
+
...getCommonAttributes(config),
|
|
567
|
+
'event.name': EVENT_MALFORMED_JSON_RESPONSE,
|
|
568
|
+
'event.timestamp': this['event.timestamp'],
|
|
569
|
+
model: this.model,
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
toLogBody() {
|
|
573
|
+
return `Malformed JSON response from ${this.model}.`;
|
|
574
|
+
}
|
|
312
575
|
}
|
|
313
576
|
export var IdeConnectionType;
|
|
314
577
|
(function (IdeConnectionType) {
|
|
315
578
|
IdeConnectionType["START"] = "start";
|
|
316
579
|
IdeConnectionType["SESSION"] = "session";
|
|
317
580
|
})(IdeConnectionType || (IdeConnectionType = {}));
|
|
581
|
+
export const EVENT_IDE_CONNECTION = 'gemini_cli.ide_connection';
|
|
318
582
|
export class IdeConnectionEvent {
|
|
319
583
|
'event.name';
|
|
320
584
|
'event.timestamp';
|
|
@@ -324,7 +588,19 @@ export class IdeConnectionEvent {
|
|
|
324
588
|
this['event.timestamp'] = new Date().toISOString();
|
|
325
589
|
this.connection_type = connection_type;
|
|
326
590
|
}
|
|
591
|
+
toOpenTelemetryAttributes(config) {
|
|
592
|
+
return {
|
|
593
|
+
...getCommonAttributes(config),
|
|
594
|
+
'event.name': EVENT_IDE_CONNECTION,
|
|
595
|
+
'event.timestamp': this['event.timestamp'],
|
|
596
|
+
connection_type: this.connection_type,
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
toLogBody() {
|
|
600
|
+
return `Ide connection. Type: ${this.connection_type}.`;
|
|
601
|
+
}
|
|
327
602
|
}
|
|
603
|
+
export const EVENT_CONVERSATION_FINISHED = 'gemini_cli.conversation_finished';
|
|
328
604
|
export class ConversationFinishedEvent {
|
|
329
605
|
'event_name';
|
|
330
606
|
'event.timestamp'; // ISO 8601;
|
|
@@ -336,6 +612,18 @@ export class ConversationFinishedEvent {
|
|
|
336
612
|
this.approvalMode = approvalMode;
|
|
337
613
|
this.turnCount = turnCount;
|
|
338
614
|
}
|
|
615
|
+
toOpenTelemetryAttributes(config) {
|
|
616
|
+
return {
|
|
617
|
+
...getCommonAttributes(config),
|
|
618
|
+
'event.name': EVENT_CONVERSATION_FINISHED,
|
|
619
|
+
'event.timestamp': this['event.timestamp'],
|
|
620
|
+
approvalMode: this.approvalMode,
|
|
621
|
+
turnCount: this.turnCount,
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
toLogBody() {
|
|
625
|
+
return `Conversation finished.`;
|
|
626
|
+
}
|
|
339
627
|
}
|
|
340
628
|
export class KittySequenceOverflowEvent {
|
|
341
629
|
'event.name';
|
|
@@ -349,7 +637,20 @@ export class KittySequenceOverflowEvent {
|
|
|
349
637
|
// Truncate to first 20 chars for logging (avoid logging sensitive data)
|
|
350
638
|
this.truncated_sequence = truncated_sequence.substring(0, 20);
|
|
351
639
|
}
|
|
640
|
+
toOpenTelemetryAttributes(config) {
|
|
641
|
+
return {
|
|
642
|
+
...getCommonAttributes(config),
|
|
643
|
+
'event.name': this['event.name'],
|
|
644
|
+
'event.timestamp': this['event.timestamp'],
|
|
645
|
+
sequence_length: this.sequence_length,
|
|
646
|
+
truncated_sequence: this.truncated_sequence,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
toLogBody() {
|
|
650
|
+
return `Kitty sequence buffer overflow: ${this.sequence_length} bytes`;
|
|
651
|
+
}
|
|
352
652
|
}
|
|
653
|
+
export const EVENT_FILE_OPERATION = 'gemini_cli.file_operation';
|
|
353
654
|
export class FileOperationEvent {
|
|
354
655
|
'event.name';
|
|
355
656
|
'event.timestamp';
|
|
@@ -369,7 +670,33 @@ export class FileOperationEvent {
|
|
|
369
670
|
this.extension = extension;
|
|
370
671
|
this.programming_language = programming_language;
|
|
371
672
|
}
|
|
673
|
+
toOpenTelemetryAttributes(config) {
|
|
674
|
+
const attributes = {
|
|
675
|
+
...getCommonAttributes(config),
|
|
676
|
+
'event.name': EVENT_FILE_OPERATION,
|
|
677
|
+
'event.timestamp': this['event.timestamp'],
|
|
678
|
+
tool_name: this.tool_name,
|
|
679
|
+
operation: this.operation,
|
|
680
|
+
};
|
|
681
|
+
if (this.lines) {
|
|
682
|
+
attributes['lines'] = this.lines;
|
|
683
|
+
}
|
|
684
|
+
if (this.mimetype) {
|
|
685
|
+
attributes['mimetype'] = this.mimetype;
|
|
686
|
+
}
|
|
687
|
+
if (this.extension) {
|
|
688
|
+
attributes['extension'] = this.extension;
|
|
689
|
+
}
|
|
690
|
+
if (this.programming_language) {
|
|
691
|
+
attributes['programming_language'] = this.programming_language;
|
|
692
|
+
}
|
|
693
|
+
return attributes;
|
|
694
|
+
}
|
|
695
|
+
toLogBody() {
|
|
696
|
+
return `File operation: ${this.operation}. Lines: ${this.lines}.`;
|
|
697
|
+
}
|
|
372
698
|
}
|
|
699
|
+
export const EVENT_INVALID_CHUNK = 'gemini_cli.chat.invalid_chunk';
|
|
373
700
|
// Add these new event interfaces
|
|
374
701
|
export class InvalidChunkEvent {
|
|
375
702
|
'event.name';
|
|
@@ -380,7 +707,22 @@ export class InvalidChunkEvent {
|
|
|
380
707
|
this['event.timestamp'] = new Date().toISOString();
|
|
381
708
|
this.error_message = error_message;
|
|
382
709
|
}
|
|
710
|
+
toOpenTelemetryAttributes(config) {
|
|
711
|
+
const attributes = {
|
|
712
|
+
...getCommonAttributes(config),
|
|
713
|
+
'event.name': EVENT_INVALID_CHUNK,
|
|
714
|
+
'event.timestamp': this['event.timestamp'],
|
|
715
|
+
};
|
|
716
|
+
if (this.error_message) {
|
|
717
|
+
attributes['error.message'] = this.error_message;
|
|
718
|
+
}
|
|
719
|
+
return attributes;
|
|
720
|
+
}
|
|
721
|
+
toLogBody() {
|
|
722
|
+
return `Invalid chunk received from stream.`;
|
|
723
|
+
}
|
|
383
724
|
}
|
|
725
|
+
export const EVENT_CONTENT_RETRY = 'gemini_cli.chat.content_retry';
|
|
384
726
|
export class ContentRetryEvent {
|
|
385
727
|
'event.name';
|
|
386
728
|
'event.timestamp';
|
|
@@ -396,7 +738,22 @@ export class ContentRetryEvent {
|
|
|
396
738
|
this.retry_delay_ms = retry_delay_ms;
|
|
397
739
|
this.model = model;
|
|
398
740
|
}
|
|
741
|
+
toOpenTelemetryAttributes(config) {
|
|
742
|
+
return {
|
|
743
|
+
...getCommonAttributes(config),
|
|
744
|
+
'event.name': EVENT_CONTENT_RETRY,
|
|
745
|
+
'event.timestamp': this['event.timestamp'],
|
|
746
|
+
attempt_number: this.attempt_number,
|
|
747
|
+
error_type: this.error_type,
|
|
748
|
+
retry_delay_ms: this.retry_delay_ms,
|
|
749
|
+
model: this.model,
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
toLogBody() {
|
|
753
|
+
return `Content retry attempt ${this.attempt_number} due to ${this.error_type}.`;
|
|
754
|
+
}
|
|
399
755
|
}
|
|
756
|
+
export const EVENT_CONTENT_RETRY_FAILURE = 'gemini_cli.chat.content_retry_failure';
|
|
400
757
|
export class ContentRetryFailureEvent {
|
|
401
758
|
'event.name';
|
|
402
759
|
'event.timestamp';
|
|
@@ -412,7 +769,22 @@ export class ContentRetryFailureEvent {
|
|
|
412
769
|
this.total_duration_ms = total_duration_ms;
|
|
413
770
|
this.model = model;
|
|
414
771
|
}
|
|
772
|
+
toOpenTelemetryAttributes(config) {
|
|
773
|
+
return {
|
|
774
|
+
...getCommonAttributes(config),
|
|
775
|
+
'event.name': EVENT_CONTENT_RETRY_FAILURE,
|
|
776
|
+
'event.timestamp': this['event.timestamp'],
|
|
777
|
+
total_attempts: this.total_attempts,
|
|
778
|
+
final_error_type: this.final_error_type,
|
|
779
|
+
total_duration_ms: this.total_duration_ms,
|
|
780
|
+
model: this.model,
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
toLogBody() {
|
|
784
|
+
return `All content retries failed after ${this.total_attempts} attempts.`;
|
|
785
|
+
}
|
|
415
786
|
}
|
|
787
|
+
export const EVENT_MODEL_ROUTING = 'gemini_cli.model_routing';
|
|
416
788
|
export class ModelRoutingEvent {
|
|
417
789
|
'event.name';
|
|
418
790
|
'event.timestamp';
|
|
@@ -432,7 +804,24 @@ export class ModelRoutingEvent {
|
|
|
432
804
|
this.failed = failed;
|
|
433
805
|
this.error_message = error_message;
|
|
434
806
|
}
|
|
807
|
+
toOpenTelemetryAttributes(config) {
|
|
808
|
+
return {
|
|
809
|
+
...getCommonAttributes(config),
|
|
810
|
+
'event.name': EVENT_MODEL_ROUTING,
|
|
811
|
+
'event.timestamp': this['event.timestamp'],
|
|
812
|
+
decision_model: this.decision_model,
|
|
813
|
+
decision_source: this.decision_source,
|
|
814
|
+
routing_latency_ms: this.routing_latency_ms,
|
|
815
|
+
reasoning: this.reasoning,
|
|
816
|
+
failed: this.failed,
|
|
817
|
+
error_message: this.error_message,
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
toLogBody() {
|
|
821
|
+
return `Model routing decision. Model: ${this.decision_model}, Source: ${this.decision_source}`;
|
|
822
|
+
}
|
|
435
823
|
}
|
|
824
|
+
export const EVENT_EXTENSION_INSTALL = 'gemini_cli.extension_install';
|
|
436
825
|
export class ExtensionInstallEvent {
|
|
437
826
|
'event.name';
|
|
438
827
|
'event.timestamp';
|
|
@@ -448,7 +837,22 @@ export class ExtensionInstallEvent {
|
|
|
448
837
|
this.extension_source = extension_source;
|
|
449
838
|
this.status = status;
|
|
450
839
|
}
|
|
840
|
+
toOpenTelemetryAttributes(config) {
|
|
841
|
+
return {
|
|
842
|
+
...getCommonAttributes(config),
|
|
843
|
+
'event.name': EVENT_EXTENSION_INSTALL,
|
|
844
|
+
'event.timestamp': this['event.timestamp'],
|
|
845
|
+
extension_name: this.extension_name,
|
|
846
|
+
extension_version: this.extension_version,
|
|
847
|
+
extension_source: this.extension_source,
|
|
848
|
+
status: this.status,
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
toLogBody() {
|
|
852
|
+
return `Installed extension ${this.extension_name}`;
|
|
853
|
+
}
|
|
451
854
|
}
|
|
855
|
+
export const EVENT_TOOL_OUTPUT_TRUNCATED = 'gemini_cli.tool_output_truncated';
|
|
452
856
|
export class ToolOutputTruncatedEvent {
|
|
453
857
|
eventName = 'tool_output_truncated';
|
|
454
858
|
'event.timestamp' = new Date().toISOString();
|
|
@@ -468,7 +872,25 @@ export class ToolOutputTruncatedEvent {
|
|
|
468
872
|
this.threshold = details.threshold;
|
|
469
873
|
this.lines = details.lines;
|
|
470
874
|
}
|
|
875
|
+
toOpenTelemetryAttributes(config) {
|
|
876
|
+
return {
|
|
877
|
+
...getCommonAttributes(config),
|
|
878
|
+
'event.name': EVENT_TOOL_OUTPUT_TRUNCATED,
|
|
879
|
+
eventName: this.eventName,
|
|
880
|
+
'event.timestamp': this['event.timestamp'],
|
|
881
|
+
tool_name: this.tool_name,
|
|
882
|
+
original_content_length: this.original_content_length,
|
|
883
|
+
truncated_content_length: this.truncated_content_length,
|
|
884
|
+
threshold: this.threshold,
|
|
885
|
+
lines: this.lines,
|
|
886
|
+
prompt_id: this.prompt_id,
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
toLogBody() {
|
|
890
|
+
return `Tool output truncated for ${this.tool_name}.`;
|
|
891
|
+
}
|
|
471
892
|
}
|
|
893
|
+
export const EVENT_EXTENSION_UNINSTALL = 'gemini_cli.extension_uninstall';
|
|
472
894
|
export class ExtensionUninstallEvent {
|
|
473
895
|
'event.name';
|
|
474
896
|
'event.timestamp';
|
|
@@ -480,7 +902,54 @@ export class ExtensionUninstallEvent {
|
|
|
480
902
|
this.extension_name = extension_name;
|
|
481
903
|
this.status = status;
|
|
482
904
|
}
|
|
905
|
+
toOpenTelemetryAttributes(config) {
|
|
906
|
+
return {
|
|
907
|
+
...getCommonAttributes(config),
|
|
908
|
+
'event.name': EVENT_EXTENSION_UNINSTALL,
|
|
909
|
+
'event.timestamp': this['event.timestamp'],
|
|
910
|
+
extension_name: this.extension_name,
|
|
911
|
+
status: this.status,
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
toLogBody() {
|
|
915
|
+
return `Uninstalled extension ${this.extension_name}`;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
export const EVENT_EXTENSION_UPDATE = 'gemini_cli.extension_update';
|
|
919
|
+
export class ExtensionUpdateEvent {
|
|
920
|
+
'event.name';
|
|
921
|
+
'event.timestamp';
|
|
922
|
+
extension_name;
|
|
923
|
+
extension_previous_version;
|
|
924
|
+
extension_version;
|
|
925
|
+
extension_source;
|
|
926
|
+
status;
|
|
927
|
+
constructor(extension_name, extension_version, extension_previous_version, extension_source, status) {
|
|
928
|
+
this['event.name'] = 'extension_update';
|
|
929
|
+
this['event.timestamp'] = new Date().toISOString();
|
|
930
|
+
this.extension_name = extension_name;
|
|
931
|
+
this.extension_version = extension_version;
|
|
932
|
+
this.extension_previous_version = extension_previous_version;
|
|
933
|
+
this.extension_source = extension_source;
|
|
934
|
+
this.status = status;
|
|
935
|
+
}
|
|
936
|
+
toOpenTelemetryAttributes(config) {
|
|
937
|
+
return {
|
|
938
|
+
...getCommonAttributes(config),
|
|
939
|
+
'event.name': EVENT_EXTENSION_UPDATE,
|
|
940
|
+
'event.timestamp': this['event.timestamp'],
|
|
941
|
+
extension_name: this.extension_name,
|
|
942
|
+
extension_version: this.extension_version,
|
|
943
|
+
extension_previous_version: this.extension_previous_version,
|
|
944
|
+
extension_source: this.extension_source,
|
|
945
|
+
status: this.status,
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
toLogBody() {
|
|
949
|
+
return `Updated extension ${this.extension_name}`;
|
|
950
|
+
}
|
|
483
951
|
}
|
|
952
|
+
export const EVENT_EXTENSION_ENABLE = 'gemini_cli.extension_enable';
|
|
484
953
|
export class ExtensionEnableEvent {
|
|
485
954
|
'event.name';
|
|
486
955
|
'event.timestamp';
|
|
@@ -492,7 +961,20 @@ export class ExtensionEnableEvent {
|
|
|
492
961
|
this.extension_name = extension_name;
|
|
493
962
|
this.setting_scope = settingScope;
|
|
494
963
|
}
|
|
964
|
+
toOpenTelemetryAttributes(config) {
|
|
965
|
+
return {
|
|
966
|
+
...getCommonAttributes(config),
|
|
967
|
+
'event.name': EVENT_EXTENSION_ENABLE,
|
|
968
|
+
'event.timestamp': this['event.timestamp'],
|
|
969
|
+
extension_name: this.extension_name,
|
|
970
|
+
setting_scope: this.setting_scope,
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
toLogBody() {
|
|
974
|
+
return `Enabled extension ${this.extension_name}`;
|
|
975
|
+
}
|
|
495
976
|
}
|
|
977
|
+
export const EVENT_MODEL_SLASH_COMMAND = 'gemini_cli.slash_command.model';
|
|
496
978
|
export class ModelSlashCommandEvent {
|
|
497
979
|
'event.name';
|
|
498
980
|
'event.timestamp';
|
|
@@ -502,7 +984,19 @@ export class ModelSlashCommandEvent {
|
|
|
502
984
|
this['event.timestamp'] = new Date().toISOString();
|
|
503
985
|
this.model_name = model_name;
|
|
504
986
|
}
|
|
987
|
+
toOpenTelemetryAttributes(config) {
|
|
988
|
+
return {
|
|
989
|
+
...getCommonAttributes(config),
|
|
990
|
+
'event.name': EVENT_MODEL_SLASH_COMMAND,
|
|
991
|
+
'event.timestamp': this['event.timestamp'],
|
|
992
|
+
model_name: this.model_name,
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
toLogBody() {
|
|
996
|
+
return `Model slash command. Model: ${this.model_name}`;
|
|
997
|
+
}
|
|
505
998
|
}
|
|
999
|
+
export const EVENT_EXTENSION_DISABLE = 'gemini_cli.extension_disable';
|
|
506
1000
|
export class ExtensionDisableEvent {
|
|
507
1001
|
'event.name';
|
|
508
1002
|
'event.timestamp';
|
|
@@ -514,5 +1008,142 @@ export class ExtensionDisableEvent {
|
|
|
514
1008
|
this.extension_name = extension_name;
|
|
515
1009
|
this.setting_scope = settingScope;
|
|
516
1010
|
}
|
|
1011
|
+
toOpenTelemetryAttributes(config) {
|
|
1012
|
+
return {
|
|
1013
|
+
...getCommonAttributes(config),
|
|
1014
|
+
'event.name': EVENT_EXTENSION_DISABLE,
|
|
1015
|
+
'event.timestamp': this['event.timestamp'],
|
|
1016
|
+
extension_name: this.extension_name,
|
|
1017
|
+
setting_scope: this.setting_scope,
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
toLogBody() {
|
|
1021
|
+
return `Disabled extension ${this.extension_name}`;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
export const EVENT_SMART_EDIT_STRATEGY = 'gemini_cli.smart_edit_strategy';
|
|
1025
|
+
export class SmartEditStrategyEvent {
|
|
1026
|
+
'event.name';
|
|
1027
|
+
'event.timestamp';
|
|
1028
|
+
strategy;
|
|
1029
|
+
constructor(strategy) {
|
|
1030
|
+
this['event.name'] = 'smart_edit_strategy';
|
|
1031
|
+
this['event.timestamp'] = new Date().toISOString();
|
|
1032
|
+
this.strategy = strategy;
|
|
1033
|
+
}
|
|
1034
|
+
toOpenTelemetryAttributes(config) {
|
|
1035
|
+
return {
|
|
1036
|
+
...getCommonAttributes(config),
|
|
1037
|
+
'event.name': EVENT_SMART_EDIT_STRATEGY,
|
|
1038
|
+
'event.timestamp': this['event.timestamp'],
|
|
1039
|
+
strategy: this.strategy,
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
toLogBody() {
|
|
1043
|
+
return `Smart Edit Tool Strategy: ${this.strategy}`;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
export const EVENT_SMART_EDIT_CORRECTION = 'gemini_cli.smart_edit_correction';
|
|
1047
|
+
export class SmartEditCorrectionEvent {
|
|
1048
|
+
'event.name';
|
|
1049
|
+
'event.timestamp';
|
|
1050
|
+
correction;
|
|
1051
|
+
constructor(correction) {
|
|
1052
|
+
this['event.name'] = 'smart_edit_correction';
|
|
1053
|
+
this['event.timestamp'] = new Date().toISOString();
|
|
1054
|
+
this.correction = correction;
|
|
1055
|
+
}
|
|
1056
|
+
toOpenTelemetryAttributes(config) {
|
|
1057
|
+
return {
|
|
1058
|
+
...getCommonAttributes(config),
|
|
1059
|
+
'event.name': EVENT_SMART_EDIT_CORRECTION,
|
|
1060
|
+
'event.timestamp': this['event.timestamp'],
|
|
1061
|
+
correction: this.correction,
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
toLogBody() {
|
|
1065
|
+
return `Smart Edit Tool Correction: ${this.correction}`;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
export const EVENT_AGENT_START = 'gemini_cli.agent.start';
|
|
1069
|
+
export class AgentStartEvent {
|
|
1070
|
+
'event.name';
|
|
1071
|
+
'event.timestamp';
|
|
1072
|
+
agent_id;
|
|
1073
|
+
agent_name;
|
|
1074
|
+
constructor(agent_id, agent_name) {
|
|
1075
|
+
this['event.name'] = 'agent_start';
|
|
1076
|
+
this['event.timestamp'] = new Date().toISOString();
|
|
1077
|
+
this.agent_id = agent_id;
|
|
1078
|
+
this.agent_name = agent_name;
|
|
1079
|
+
}
|
|
1080
|
+
toOpenTelemetryAttributes(config) {
|
|
1081
|
+
return {
|
|
1082
|
+
...getCommonAttributes(config),
|
|
1083
|
+
'event.name': EVENT_AGENT_START,
|
|
1084
|
+
'event.timestamp': this['event.timestamp'],
|
|
1085
|
+
agent_id: this.agent_id,
|
|
1086
|
+
agent_name: this.agent_name,
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
toLogBody() {
|
|
1090
|
+
return `Agent ${this.agent_name} started. ID: ${this.agent_id}`;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
export const EVENT_AGENT_FINISH = 'gemini_cli.agent.finish';
|
|
1094
|
+
export class AgentFinishEvent {
|
|
1095
|
+
'event.name';
|
|
1096
|
+
'event.timestamp';
|
|
1097
|
+
agent_id;
|
|
1098
|
+
agent_name;
|
|
1099
|
+
duration_ms;
|
|
1100
|
+
turn_count;
|
|
1101
|
+
terminate_reason;
|
|
1102
|
+
constructor(agent_id, agent_name, duration_ms, turn_count, terminate_reason) {
|
|
1103
|
+
this['event.name'] = 'agent_finish';
|
|
1104
|
+
this['event.timestamp'] = new Date().toISOString();
|
|
1105
|
+
this.agent_id = agent_id;
|
|
1106
|
+
this.agent_name = agent_name;
|
|
1107
|
+
this.duration_ms = duration_ms;
|
|
1108
|
+
this.turn_count = turn_count;
|
|
1109
|
+
this.terminate_reason = terminate_reason;
|
|
1110
|
+
}
|
|
1111
|
+
toOpenTelemetryAttributes(config) {
|
|
1112
|
+
return {
|
|
1113
|
+
...getCommonAttributes(config),
|
|
1114
|
+
'event.name': EVENT_AGENT_FINISH,
|
|
1115
|
+
'event.timestamp': this['event.timestamp'],
|
|
1116
|
+
agent_id: this.agent_id,
|
|
1117
|
+
agent_name: this.agent_name,
|
|
1118
|
+
duration_ms: this.duration_ms,
|
|
1119
|
+
turn_count: this.turn_count,
|
|
1120
|
+
terminate_reason: this.terminate_reason,
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
toLogBody() {
|
|
1124
|
+
return `Agent ${this.agent_name} finished. Reason: ${this.terminate_reason}. Duration: ${this.duration_ms}ms. Turns: ${this.turn_count}.`;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
export const EVENT_WEB_FETCH_FALLBACK_ATTEMPT = 'gemini_cli.web_fetch_fallback_attempt';
|
|
1128
|
+
export class WebFetchFallbackAttemptEvent {
|
|
1129
|
+
'event.name';
|
|
1130
|
+
'event.timestamp';
|
|
1131
|
+
reason;
|
|
1132
|
+
constructor(reason) {
|
|
1133
|
+
this['event.name'] = 'web_fetch_fallback_attempt';
|
|
1134
|
+
this['event.timestamp'] = new Date().toISOString();
|
|
1135
|
+
this.reason = reason;
|
|
1136
|
+
}
|
|
1137
|
+
toOpenTelemetryAttributes(config) {
|
|
1138
|
+
return {
|
|
1139
|
+
...getCommonAttributes(config),
|
|
1140
|
+
'event.name': EVENT_WEB_FETCH_FALLBACK_ATTEMPT,
|
|
1141
|
+
'event.timestamp': this['event.timestamp'],
|
|
1142
|
+
reason: this.reason,
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
toLogBody() {
|
|
1146
|
+
return `Web fetch fallback attempt. Reason: ${this.reason}`;
|
|
1147
|
+
}
|
|
517
1148
|
}
|
|
518
1149
|
//# sourceMappingURL=types.js.map
|