Class: AgentHarness::Providers::Gemini

Inherits:
Base
  • Object
show all
Defined in:
lib/agent_harness/providers/gemini.rb

Overview

Google Gemini CLI provider

Provides integration with the Google Gemini CLI tool.

Constant Summary collapse

MODEL_PATTERN =

Model name pattern for Gemini models

/^gemini-[\d.]+-(?:pro|flash|ultra)(?:-\d+)?$/i

Instance Attribute Summary

Attributes inherited from Base

#config, #executor, #logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#configure, #initialize, #send_message

Methods included from Adapter

#dangerous_mode_flags, #fetch_mcp_servers, #health_status, included, #send_message, #session_flags, #supports_dangerous_mode?, #supports_mcp?, #supports_sessions?, #validate_config

Constructor Details

This class inherits a constructor from AgentHarness::Providers::Base

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/agent_harness/providers/gemini.rb', line 21

def available?
  executor = AgentHarness.configuration.command_executor
  !!executor.which(binary_name)
end

.binary_nameObject



17
18
19
# File 'lib/agent_harness/providers/gemini.rb', line 17

def binary_name
  "gemini"
end

.discover_modelsObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/agent_harness/providers/gemini.rb', line 48

def discover_models
  return [] unless available?

  # Gemini CLI doesn't have a standard model listing command
  # Return common models
  [
    {name: "gemini-2.0-flash", family: "gemini-2-0-flash", tier: "standard", provider: "gemini"},
    {name: "gemini-2.5-pro", family: "gemini-2-5-pro", tier: "advanced", provider: "gemini"},
    {name: "gemini-1.5-pro", family: "gemini-1-5-pro", tier: "standard", provider: "gemini"},
    {name: "gemini-1.5-flash", family: "gemini-1-5-flash", tier: "mini", provider: "gemini"}
  ]
end

.firewall_requirementsObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/agent_harness/providers/gemini.rb', line 26

def firewall_requirements
  {
    domains: [
      "generativelanguage.googleapis.com",
      "oauth2.googleapis.com",
      "accounts.google.com",
      "www.googleapis.com"
    ],
    ip_ranges: []
  }
end

.instruction_file_pathsObject



38
39
40
41
42
43
44
45
46
# File 'lib/agent_harness/providers/gemini.rb', line 38

def instruction_file_paths
  [
    {
      path: "GEMINI.md",
      description: "Google Gemini agent instructions",
      symlink: true
    }
  ]
end

.model_family(provider_model_name) ⇒ Object



61
62
63
64
# File 'lib/agent_harness/providers/gemini.rb', line 61

def model_family(provider_model_name)
  # Strip version suffix: "gemini-1.5-pro-001" -> "gemini-1.5-pro"
  provider_model_name.sub(/-\d+$/, "")
end

.provider_model_name(family_name) ⇒ Object



66
67
68
# File 'lib/agent_harness/providers/gemini.rb', line 66

def provider_model_name(family_name)
  family_name
end

.provider_nameObject



13
14
15
# File 'lib/agent_harness/providers/gemini.rb', line 13

def provider_name
  :gemini
end

.supports_model_family?(family_name) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/agent_harness/providers/gemini.rb', line 70

def supports_model_family?(family_name)
  MODEL_PATTERN.match?(family_name) || family_name.start_with?("gemini-")
end

Instance Method Details

#capabilitiesObject



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/agent_harness/providers/gemini.rb', line 83

def capabilities
  {
    streaming: true,
    file_upload: true,
    vision: true,
    tool_use: true,
    json_mode: true,
    mcp: false,
    dangerous_mode: false
  }
end

#display_nameObject



79
80
81
# File 'lib/agent_harness/providers/gemini.rb', line 79

def display_name
  "Google Gemini"
end

#error_patternsObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/agent_harness/providers/gemini.rb', line 95

def error_patterns
  {
    rate_limited: [
      /rate.?limit/i,
      /quota.?exceeded/i,
      /429/
    ],
    auth_expired: [
      /authentication/i,
      /unauthorized/i,
      /invalid.?credentials/i
    ],
    transient: [
      /timeout/i,
      /temporary/i,
      /503/
    ]
  }
end

#nameObject



75
76
77
# File 'lib/agent_harness/providers/gemini.rb', line 75

def name
  "gemini"
end