/** * Gemini Adapter * * Integrates the Google Gemini Developer API (Google AI Studio / * generativelanguage.googleapis.com) with the SwarmOrchestrator. This is the * consumer-facing Gemini path — for Gemini on Google Cloud (Vertex AI) use * `VertexAIAdapter` instead. * * Supports Gemini 2.x / 2.5 models with system instructions, generation * config (temperature, max output tokens), and thinking budgets. * * Usage — built-in fetch (Gemini Developer API): * const adapter = new GeminiAdapter(); * adapter.registerAgent('researcher', { * model: 'gemini-2.5-flash', * apiKey: process.env.GEMINI_API_KEY, * systemPrompt: 'You are a meticulous researcher.', * }); * * Usage — bring-your-own client (@google/genai or compatible): * import { GoogleGenAI } from '@google/genai'; * const genai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); * adapter.registerAgent('pro', { * model: 'gemini-2.5-pro', * client: { generateContent: (params) => genai.models.generateContent(params) }, * }); * * @module GeminiAdapter * @version 1.0.0 */ import { BaseAdapter } from './base-adapter'; import type { AdapterCapabilities, AgentPayload, AgentContext, AgentResult } from '../types/agent-adapter'; /** A single content part in a Gemini request/response */ export interface GeminiContentPart { text?: string; /** Inline binary data (images, etc.) — base64 + mime type */ inlineData?: { mimeType: string; data: string; }; } /** A content turn (role + parts) in a Gemini conversation */ export interface GeminiContent { role?: 'user' | 'model'; parts: GeminiContentPart[]; } /** Response shape returned by generateContent (SDK and REST are compatible) */ export interface GeminiGenerateResponse { /** SDK convenience accessor — full concatenated text, when available */ text?: string; candidates?: Array<{ content?: GeminiContent; finishReason?: string; }>; usageMetadata?: { promptTokenCount?: number; candidatesTokenCount?: number; totalTokenCount?: number; thoughtsTokenCount?: number; }; } /** * Minimal interface for a Gemini generateContent client. Matches the * `@google/genai` SDK's `models.generateContent` signature; users supply * their own SDK instance — no hard dependency (BYOC). */ export interface GeminiGenerateClient { generateContent(params: { model: string; contents: GeminiContent[] | string; config?: Record; }): Promise; } /** Configuration for a registered Gemini agent */ export interface GeminiAgentConfig { /** Model name — e.g. 'gemini-2.5-flash', 'gemini-2.5-pro' (default: 'gemini-2.5-flash') */ model?: string; /** Gemini API key — falls back to GEMINI_API_KEY env var */ apiKey?: string; /** Base URL override (default: 'https://generativelanguage.googleapis.com/v1beta') */ baseUrl?: string; /** System instruction prepended to every request */ systemPrompt?: string; /** Maximum output tokens */ maxOutputTokens?: number; /** Temperature (0.0 – 2.0 for Gemini). Default: model default */ temperature?: number; /** * Thinking budget in tokens for thinking-capable models * (e.g. gemini-2.5-*). 0 disables thinking; omit for model default. */ thinkingBudget?: number; /** * Bring-your-own `@google/genai`-compatible client. If supplied, * apiKey / baseUrl are ignored and this client is used directly. */ client?: GeminiGenerateClient; /** Additional headers to send with fetch-based requests */ headers?: Record; /** Request timeout in milliseconds (default: 120000) */ timeout?: number; } /** * Adapter that connects Google Gemini models (Gemini Developer API) to the * SwarmOrchestrator. BYOC: supply a `@google/genai`-compatible client, or * let the adapter call the REST API directly with a `GEMINI_API_KEY`. */ export declare class GeminiAdapter extends BaseAdapter { readonly name = "gemini"; readonly version = "1.0.0"; private agents; get capabilities(): AdapterCapabilities; /** * Register a Gemini-powered agent. * * @param agentId Unique identifier used in `delegateTask` calls. * @param config Gemini agent configuration. */ registerAgent(agentId: string, config?: GeminiAgentConfig): void; executeAgent(agentId: string, payload: AgentPayload, context: AgentContext): Promise; shutdown(): Promise; private _generate; } //# sourceMappingURL=gemini-adapter.d.ts.map