From 521708e294fe7eb16683d137e46aa36be4b9ddf5 Mon Sep 17 00:00:00 2001 From: Brandon Keiji Date: Wed, 14 May 2025 22:14:15 +0000 Subject: refactor: break submitQuery into smaller functions (#350) --- packages/server/src/core/turn.ts | 45 ++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'packages/server/src') diff --git a/packages/server/src/core/turn.ts b/packages/server/src/core/turn.ts index 8f473986..dd2a08ce 100644 --- a/packages/server/src/core/turn.ts +++ b/packages/server/src/core/turn.ts @@ -78,16 +78,43 @@ export interface ServerToolCallConfirmationDetails { details: ToolCallConfirmationDetails; } +export type ServerGeminiContentEvent = { + type: GeminiEventType.Content; + value: string; +}; + +export type ServerGeminiToolCallRequestEvent = { + type: GeminiEventType.ToolCallRequest; + value: ToolCallRequestInfo; +}; + +export type ServerGeminiToolCallResponseEvent = { + type: GeminiEventType.ToolCallResponse; + value: ToolCallResponseInfo; +}; + +export type ServerGeminiToolCallConfirmationEvent = { + type: GeminiEventType.ToolCallConfirmation; + value: ServerToolCallConfirmationDetails; +}; + +export type ServerGeminiUserCancelledEvent = { + type: GeminiEventType.UserCancelled; +}; + +export type ServerGeminiErrorEvent = { + type: GeminiEventType.Error; + value: GeminiErrorEventValue; +}; + +// The original union type, now composed of the individual types export type ServerGeminiStreamEvent = - | { type: GeminiEventType.Content; value: string } - | { type: GeminiEventType.ToolCallRequest; value: ToolCallRequestInfo } - | { type: GeminiEventType.ToolCallResponse; value: ToolCallResponseInfo } - | { - type: GeminiEventType.ToolCallConfirmation; - value: ServerToolCallConfirmationDetails; - } - | { type: GeminiEventType.UserCancelled } - | { type: GeminiEventType.Error; value: GeminiErrorEventValue }; + | ServerGeminiContentEvent + | ServerGeminiToolCallRequestEvent + | ServerGeminiToolCallResponseEvent + | ServerGeminiToolCallConfirmationEvent + | ServerGeminiUserCancelledEvent + | ServerGeminiErrorEvent; // A turn manages the agentic loop turn within the server context. export class Turn { -- cgit v1.2.3