Skip to content

feat: add gemini_sdk package wrapping Google Gemini CLI#75

Open
Norbert515 wants to merge 1 commit intomainfrom
feat/gemini-sdk
Open

feat: add gemini_sdk package wrapping Google Gemini CLI#75
Norbert515 wants to merge 1 commit intomainfrom
feat/gemini-sdk

Conversation

@Norbert515
Copy link
Owner

Summary

  • Creates packages/gemini_sdk/ — a Dart wrapper for Gemini CLI that works natively with agent_sdk types
  • Subprocess-per-turn architecture using --output-format stream-json for JSONL event streaming
  • Multi-turn sessions via --resume <session-id>
  • GeminiAgentClient bridge implementing AgentClient interface

Architecture

Unlike Codex CLI (persistent app-server subprocess with bidirectional JSON-RPC), Gemini CLI has no stdin-based protocol. Each turn spawns a new gemini -p "..." --output-format stream-json process, parses JSONL events from stdout, and exits when complete.

Transport: GeminiTransport — one subprocess per turn, yields GeminiEvent stream
Events: Sealed hierarchy matching stream-json output — init, message, tool_use, tool_result, error, result
Client: GeminiClient — manages conversation state using agent_sdk types directly (no intermediate type system)
Bridge: GeminiAgentClient — pure delegation (no type mapping needed since client already uses agent_sdk types)

Auth & Permissions

Authentication: Supports both:

  • GEMINI_API_KEY env var (headless-from-scratch / CI)
  • Cached Google login credentials from ~/.gemini/ (after one interactive gemini session)

Tool approval: Defaults to --approval-mode yolo because 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

  • vide_core migration from ClaudeClient to AgentClient (follow-up)
  • Integration with vide TUI agent selection (follow-up)

Verification

  • dart analyze — 0 issues
  • dart test — 337/337 passing (330 existing + 7 new)
  • dart format — all files formatted

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments