mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 03:54:43 -07:00
refactor: make log/event structure clear (#10467)
This commit is contained in:
committed by
GitHub
parent
cce245738e
commit
83075b2800
@@ -39,6 +39,7 @@ import {
|
||||
logUserPrompt,
|
||||
AuthType,
|
||||
getOauthClient,
|
||||
UserPromptEvent,
|
||||
} from '@google/gemini-cli-core';
|
||||
import {
|
||||
initializeApp,
|
||||
@@ -436,14 +437,15 @@ export async function main() {
|
||||
}
|
||||
|
||||
const prompt_id = Math.random().toString(16).slice(2);
|
||||
logUserPrompt(config, {
|
||||
'event.name': 'user_prompt',
|
||||
'event.timestamp': new Date().toISOString(),
|
||||
prompt: input,
|
||||
prompt_id,
|
||||
auth_type: config.getContentGeneratorConfig()?.authType,
|
||||
prompt_length: input.length,
|
||||
});
|
||||
logUserPrompt(
|
||||
config,
|
||||
new UserPromptEvent(
|
||||
input.length,
|
||||
prompt_id,
|
||||
config.getContentGeneratorConfig()?.authType,
|
||||
input,
|
||||
),
|
||||
);
|
||||
|
||||
const nonInteractiveConfig = await validateNonInteractiveAuth(
|
||||
settings.merged.security?.auth?.selectedType,
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
MCPServerConfig,
|
||||
DiscoveredMCPTool,
|
||||
StreamEventType,
|
||||
ToolCallEvent,
|
||||
DEFAULT_GEMINI_MODEL,
|
||||
DEFAULT_GEMINI_MODEL_AUTO,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
@@ -369,20 +370,21 @@ class Session {
|
||||
|
||||
const errorResponse = (error: Error) => {
|
||||
const durationMs = Date.now() - startTime;
|
||||
logToolCall(this.config, {
|
||||
'event.name': 'tool_call',
|
||||
'event.timestamp': new Date().toISOString(),
|
||||
prompt_id: promptId,
|
||||
function_name: fc.name ?? '',
|
||||
function_args: args,
|
||||
duration_ms: durationMs,
|
||||
success: false,
|
||||
error: error.message,
|
||||
tool_type:
|
||||
logToolCall(
|
||||
this.config,
|
||||
new ToolCallEvent(
|
||||
undefined,
|
||||
fc.name ?? '',
|
||||
args,
|
||||
durationMs,
|
||||
false,
|
||||
promptId,
|
||||
typeof tool !== 'undefined' && tool instanceof DiscoveredMCPTool
|
||||
? 'mcp'
|
||||
: 'native',
|
||||
});
|
||||
error.message,
|
||||
),
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
@@ -488,19 +490,20 @@ class Session {
|
||||
});
|
||||
|
||||
const durationMs = Date.now() - startTime;
|
||||
logToolCall(this.config, {
|
||||
'event.name': 'tool_call',
|
||||
'event.timestamp': new Date().toISOString(),
|
||||
function_name: fc.name,
|
||||
function_args: args,
|
||||
duration_ms: durationMs,
|
||||
success: true,
|
||||
prompt_id: promptId,
|
||||
tool_type:
|
||||
logToolCall(
|
||||
this.config,
|
||||
new ToolCallEvent(
|
||||
undefined,
|
||||
fc.name ?? '',
|
||||
args,
|
||||
durationMs,
|
||||
true,
|
||||
promptId,
|
||||
typeof tool !== 'undefined' && tool instanceof DiscoveredMCPTool
|
||||
? 'mcp'
|
||||
: 'native',
|
||||
});
|
||||
),
|
||||
);
|
||||
|
||||
return convertToFunctionResponse(fc.name, callId, toolResult.llmContent);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user