Google Gemini SDK adapter for the Makaio AI framework.
import { createGeminiSDKAdapter, GeminiAdapter } from ' @makaio/ai-adapters-gemini-sdk ' ;
import { MakaioBus } from ' @makaio/bus-core ' ;
import { AdapterSubjects } from ' @makaio/contracts ' ;
// Using the factory function (recommended)
const adapter = await createGeminiSDKAdapter ();
const result = await MakaioBus . request (AdapterSubjects . startAgent , {
adapterId: adapter . adapterId ,
initialMessage: ' Inspect this repository ' ,
// Or using the class directly
const directAdapter = new GeminiAdapter ();
await directAdapter . init ();
This adapter follows the three-layer architecture pattern:
GeminiAdapter extends AIAdapter
-> creates via agentFactory()
GeminiAgent extends AIAgent
-> receives connector via connectorFactory()
GeminiConnector extends AIAgentConnector
Layers:
Layer Class Responsibility Adapter GeminiAdapterFactory for agents, handles adapter.startAgent RPC Agent GeminiAgentWires events to global bus, manages lifecycle Connector GeminiConnectorSDK-level bridge to Google Gemini
Session/Turn Management:
Class Purpose GeminiConnectorSessionSession lifecycle, prompt cache preservation GeminiConnectorTurnIndividual turn handling UserMessageQueueInternal connector queue from adapter core
tools - Tool/function calling support
streaming - Streaming responses
systemPrompt:override - Replace/set the system prompt
systemPrompt:append - Append to the adapter’s default system prompt
Tool approval workflow via registerToolApprovalHandler
Replace and interrupt delivery modes
Export Description GeminiAdapterMain adapter class createGeminiSDKAdapterFactory function (creates and initializes) GeminiSdkAdapterNameAdapter identifier constant
Export Description GeminiAgentAgent class (middle layer) GeminiConnectorConnector class (SDK bridge) GeminiAgentLegacyLegacy alias for GeminiConnector
Export Description GeminiConnectorSessionSession abstraction GeminiConnectorTurnTurn abstraction UserMessageQueueInternal connector queue from adapter core
Export Description GeminiConnectorNamespaceBus namespace for connector events GeminiConnectorSubjectsSubject constants for bus messaging GeminiAgentMetadataAgent metadata type GeminiConnectorConfigConnector configuration type GeminiAgentConnectorConfigAgent connector config type GeminiSessionConfigSession configuration type
Export Description registerToolApprovalHandlerRegister handler for tool approval requests requestToolApprovalRequest tool approval toGlobalToolApprovalConvert to global approval format fromGlobalToolApprovalConvert from global approval format
Export Description GeminiSdkProviderConfigSchemaZod schema for provider config
Install the peer SDK packages provided by the framework workspace or your package manager. Runtime
sessions require Google Gemini credentials. The adapter supports:
API-key auth via the canonical Google provider credential, mapped to GEMINI_API_KEY.
OAuth auth via the google-oauth provider path used by the Gemini CLI core.
If an API-key credential ref is configured, the adapter uses API-key auth and fails fast when the
resolved key is empty. OAuth fallback is used only when no API-key credential is supplied.
├── index.ts # Package exports
├── adapter.ts # GeminiAdapter class
├── agent.ts # GeminiAgent class
├── connector.ts # GeminiConnector class
├── session.ts # Session management
├── turn.ts # Turn management
├── config.ts # Configuration utilities
├── constants.ts # Adapter constants
├── definition.ts # Internal adapter definition
├── models.ts # Model catalog
├── package.ts # MakaioExtension package descriptor
├── provider.ts # Provider registration
├── provider.fetcher.ts # Model fetcher
├── rate-limiter.ts # Rate limiting
├── server.ts # Server entrypoint exporting the package descriptor
├── schemas.ts # Zod schemas
├── tool-handling.ts # Tool approval utilities
├── namespaces/ # Bus namespace definitions
├── types/ # TypeScript types
└── utils/ # Utility functions
Part of the Makaio AI framework