/** * Google Direct Integration Module - Pure Client (LLM Provider Refactoring Phase 4) * * Features: * - Direct Google Generative AI API integration * - Streaming and non-streaming responses returning LLMResponse * - Function/tool calling detection (NO execution) * - Proper error handling and retry logic * - Browser-safe configuration injection * - Pure client: only calls APIs and returns structured data * * Implementation Details: * - Uses official @google/generative-ai package for reliable API access * - Converts AI SDK message format to Google Generative AI format * - Returns LLMResponse with type='text' or type='tool_calls' * - Streaming support with chunk-by-chunk processing via onChunk callback * - Error handling with descriptive messages * - Configuration injection from llm-config module * - NO event emission, NO storage, NO tool execution * * Recent Changes: * - 2026-03-13: Switched world reasoning overrides to `default`/`none`, where `default` omits thinking config and `none` uses a zero-budget explicit override. * - 2026-03-12: Reclassified streaming abort logs as info-level cancellations to suppress expected stop/edit noise. * - 2026-02-15: Stopped replaying historical tool call/response parts as Google `functionCall`/`functionResponse` in conversation conversion to avoid 400 errors requiring `thought_signature` on replayed calls. * - 2026-02-13: Added transport-level AbortSignal wiring to Google SDK request options where supported. * - 2026-02-13: Added abort-signal checks for streaming and non-streaming execution paths. * - 2025-11-09: Phase 4 - Removed ALL tool execution logic (~200 lines) * - Provider is now a pure client - only API calls and data transformation * - Returns LLMResponse interface with type discriminator * - Filters invalid function calls (empty/missing names) and logs warnings * - Note: Google API doesn't provide usage information in response * - 2025-11-08: Removed ALL event emission from provider * - Streaming uses onChunk callback instead of direct SSE emission */ import { GoogleGenerativeAI, GenerativeModel } from '@google/generative-ai'; import { World, Agent, ChatMessage, LLMResponse } from './types.js'; import { GoogleConfig } from './llm-config.js'; /** * Google client factory */ export declare function createGoogleClient(config: GoogleConfig): GoogleGenerativeAI; /** * Create Google model instance */ export declare function createGoogleModel(client: GoogleGenerativeAI, modelName: string, tools?: any[]): GenerativeModel; /** * Streaming Google response handler - Pure client (no tool execution) * Returns LLMResponse with type='text' or type='tool_calls' */ export declare function streamGoogleResponse(client: GoogleGenerativeAI, model: string, messages: ChatMessage[], agent: Agent, mcpTools: Record, world: World, onChunk: (chunk: { content?: string; reasoningContent?: string; }) => void, messageId: string, abortSignal?: AbortSignal): Promise; /** * Non-streaming Google response handler - Pure client (no tool execution) * Returns LLMResponse with type='text' or type='tool_calls' */ export declare function generateGoogleResponse(client: GoogleGenerativeAI, model: string, messages: ChatMessage[], agent: Agent, mcpTools: Record, world: World, abortSignal?: AbortSignal): Promise; /** * Factory function to create Google client for agent */ export declare function createGoogleClientForAgent(agent: Agent): GoogleGenerativeAI;