feat: add gemini_sdk package wrapping Google Gemini CLI#75
Open
Norbert515 wants to merge 1 commit intomainfrom
Open
feat: add gemini_sdk package wrapping Google Gemini CLI#75Norbert515 wants to merge 1 commit intomainfrom
Norbert515 wants to merge 1 commit intomainfrom
Conversation
Create a Dart SDK wrapper for Gemini CLI (google-gemini/gemini-cli) that works natively with agent_sdk types. Uses subprocess-per-turn transport with --output-format stream-json for JSONL event streaming and --resume for multi-turn sessions. Key components: - GeminiTransport: spawns one subprocess per turn, parses JSONL events - GeminiEvent sealed hierarchy: init, message, tool_use, tool_result, error, result - GeminiClient: manages conversation state using agent_sdk types directly - GeminiAgentClient: thin bridge implementing AgentClient (pure delegation) - GeminiConfig: PODO with toCliArgs(), defaults to yolo approval mode Auth supports both GEMINI_API_KEY and cached Google login credentials.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packages/gemini_sdk/— a Dart wrapper for Gemini CLI that works natively withagent_sdktypes--output-format stream-jsonfor JSONL event streaming--resume <session-id>GeminiAgentClientbridge implementingAgentClientinterfaceArchitecture
Unlike Codex CLI (persistent
app-serversubprocess with bidirectional JSON-RPC), Gemini CLI has no stdin-based protocol. Each turn spawns a newgemini -p "..." --output-format stream-jsonprocess, parses JSONL events from stdout, and exits when complete.Transport:
GeminiTransport— one subprocess per turn, yieldsGeminiEventstreamEvents: Sealed hierarchy matching stream-json output —
init,message,tool_use,tool_result,error,resultClient:
GeminiClient— manages conversation state usingagent_sdktypes directly (no intermediate type system)Bridge:
GeminiAgentClient— pure delegation (no type mapping needed since client already usesagent_sdktypes)Auth & Permissions
Authentication: Supports both:
GEMINI_API_KEYenv var (headless-from-scratch / CI)~/.gemini/(after one interactivegeminisession)Tool approval: Defaults to
--approval-mode yolobecause headless mode has no stdin-based approval protocol — tools requiring confirmation are auto-denied unless a permissive mode is set.What's NOT in this PR
ClaudeClienttoAgentClient(follow-up)Verification
dart analyze— 0 issuesdart test— 337/337 passing (330 existing + 7 new)dart format— all files formatted