/** * Vertex AI Adapter * * Integrates Google Vertex AI (Gemini models, PaLM, custom endpoints) * with the SwarmOrchestrator. * * Supports: * - Gemini chat/generation (via user-supplied client) * - Function calling / tool use * - Multi-modal inputs (text + images) * - Custom Vertex AI endpoints * * Usage: * const adapter = new VertexAIAdapter(); * adapter.registerModel('analyst', { * client: myVertexClient, * model: 'gemini-2.0-flash', * }); * * @module VertexAIAdapter * @version 1.0.0 */ import { BaseAdapter } from './base-adapter'; import type { AdapterCapabilities, AgentPayload, AgentContext, AgentResult } from '../types/agent-adapter'; /** Vertex AI function declaration for tool use */ export interface VertexFunctionDeclaration { name: string; description: string; parameters: Record; } /** A content part (text or inline data) */ export interface VertexContentPart { text?: string; inlineData?: { mimeType: string; data: string; }; } /** Response from Vertex AI */ export interface VertexGenerateResponse { /** Generated text content */ text: string; /** Function calls requested by the model */ functionCalls?: Array<{ name: string; args: Record; }>; /** Safety ratings */ safetyRatings?: Array<{ category: string; probability: string; }>; /** Token usage */ usageMetadata?: { promptTokenCount: number; candidatesTokenCount: number; totalTokenCount: number; }; /** Finish reason */ finishReason?: string; } /** * Minimal interface for a Vertex AI generative model client. * Compatible with `@google-cloud/vertexai` GenerativeModel. */ export interface VertexGenerativeClient { generateContent(request: { contents: Array<{ role: string; parts: VertexContentPart[]; }>; systemInstruction?: { parts: VertexContentPart[]; }; tools?: Array<{ functionDeclarations: VertexFunctionDeclaration[]; }>; }): Promise<{ response: VertexGenerateResponse; }>; } /** * Function executor for tool use. * Called when Gemini requests a function call. */ export type VertexFunctionExecutor = (name: string, args: Record) => Promise; /** Configuration for a registered Vertex AI agent */ export interface VertexAIAgentConfig { /** The Vertex AI client instance */ client: VertexGenerativeClient; /** Model name (default: 'gemini-2.0-flash') */ model?: string; /** System instruction */ systemInstruction?: string; /** Function declarations for tool use */ functions?: VertexFunctionDeclaration[]; /** Function executor for tool calls */ functionExecutor?: VertexFunctionExecutor; /** Maximum tool-use loop iterations (default: 10) */ maxIterations?: number; /** Per-invocation timeout in ms (default: 60000) */ timeoutMs?: number; } /** * Adapter for Google Vertex AI (Gemini, PaLM, custom endpoints). * * Each registered model is exposed as a named agent. Supports * multi-turn tool use loops when functions are configured. */ export declare class VertexAIAdapter extends BaseAdapter { readonly name = "vertex-ai"; readonly version = "1.0.0"; private models; get capabilities(): AdapterCapabilities; /** * Register a Vertex AI model as a named agent. */ registerModel(agentId: string, config: VertexAIAgentConfig): void; executeAgent(agentId: string, payload: AgentPayload, _context: AgentContext): Promise; shutdown(): Promise; } //# sourceMappingURL=vertex-ai-adapter.d.ts.map