Module: AgentHarness::Providers::Adapter
- Included in:
- Base
- Defined in:
- lib/agent_harness/providers/adapter.rb
Overview
Interface that all providers must implement
This module defines the contract that provider implementations must follow. Include this module in provider classes to ensure they implement the required interface.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#auth_type ⇒ Symbol
Authentication type for this provider.
-
#build_mcp_flags(mcp_servers, working_dir: nil) ⇒ Array<String>
Build provider-specific MCP flags/arguments for CLI invocation.
-
#capabilities ⇒ Hash
Provider capabilities.
-
#dangerous_mode_flags ⇒ Array<String>
Get dangerous mode flags.
-
#error_patterns ⇒ Hash<Symbol, Array<Regexp>>
Error patterns for classification.
-
#fetch_mcp_servers ⇒ Array<Hash>
Fetch configured MCP servers.
-
#health_status ⇒ Hash
Health check.
-
#send_message(prompt:, **options) ⇒ Response
Send a message/prompt to the provider.
-
#session_flags(session_id) ⇒ Array<String>
Get session flags for continuation.
-
#supported_mcp_transports ⇒ Array<String>
Supported MCP transport types for this provider.
-
#supports_dangerous_mode? ⇒ Boolean
Check if provider supports dangerous mode.
-
#supports_mcp? ⇒ Boolean
Check if provider supports MCP.
-
#supports_sessions? ⇒ Boolean
Check if provider supports session continuation.
-
#validate_config ⇒ Hash
Validate provider configuration.
-
#validate_mcp_servers!(mcp_servers) ⇒ Object
Validate that this provider can handle the given MCP servers.
Class Method Details
.included(base) ⇒ Object
19 20 21 |
# File 'lib/agent_harness/providers/adapter.rb', line 19 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#auth_type ⇒ Symbol
Authentication type for this provider
109 110 111 |
# File 'lib/agent_harness/providers/adapter.rb', line 109 def auth_type :api_key end |
#build_mcp_flags(mcp_servers, working_dir: nil) ⇒ Array<String>
Build provider-specific MCP flags/arguments for CLI invocation
139 140 141 |
# File 'lib/agent_harness/providers/adapter.rb', line 139 def build_mcp_flags(mcp_servers, working_dir: nil) [] end |
#capabilities ⇒ Hash
Provider capabilities
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/agent_harness/providers/adapter.rb', line 86 def capabilities { streaming: false, file_upload: false, vision: false, tool_use: false, json_mode: false, mcp: false, dangerous_mode: false } end |
#dangerous_mode_flags ⇒ Array<String>
Get dangerous mode flags
189 190 191 |
# File 'lib/agent_harness/providers/adapter.rb', line 189 def dangerous_mode_flags [] end |
#error_patterns ⇒ Hash<Symbol, Array<Regexp>>
Error patterns for classification
101 102 103 |
# File 'lib/agent_harness/providers/adapter.rb', line 101 def error_patterns {} end |
#fetch_mcp_servers ⇒ Array<Hash>
Fetch configured MCP servers
123 124 125 |
# File 'lib/agent_harness/providers/adapter.rb', line 123 def fetch_mcp_servers [] end |
#health_status ⇒ Hash
Health check
218 219 220 |
# File 'lib/agent_harness/providers/adapter.rb', line 218 def health_status {healthy: true, message: "OK"} end |
#send_message(prompt:, **options) ⇒ Response
Send a message/prompt to the provider
79 80 81 |
# File 'lib/agent_harness/providers/adapter.rb', line 79 def (prompt:, **) raise NotImplementedError, "#{self.class} must implement #send_message" end |
#session_flags(session_id) ⇒ Array<String>
Get session flags for continuation
204 205 206 |
# File 'lib/agent_harness/providers/adapter.rb', line 204 def session_flags(session_id) [] end |
#supported_mcp_transports ⇒ Array<String>
Supported MCP transport types for this provider
130 131 132 |
# File 'lib/agent_harness/providers/adapter.rb', line 130 def supported_mcp_transports [] end |
#supports_dangerous_mode? ⇒ Boolean
Check if provider supports dangerous mode
182 183 184 |
# File 'lib/agent_harness/providers/adapter.rb', line 182 def supports_dangerous_mode? capabilities[:dangerous_mode] end |
#supports_mcp? ⇒ Boolean
Check if provider supports MCP
116 117 118 |
# File 'lib/agent_harness/providers/adapter.rb', line 116 def supports_mcp? capabilities[:mcp] end |
#supports_sessions? ⇒ Boolean
Check if provider supports session continuation
196 197 198 |
# File 'lib/agent_harness/providers/adapter.rb', line 196 def supports_sessions? false end |
#validate_config ⇒ Hash
Validate provider configuration
211 212 213 |
# File 'lib/agent_harness/providers/adapter.rb', line 211 def validate_config {valid: true, errors: []} end |
#validate_mcp_servers!(mcp_servers) ⇒ Object
Validate that this provider can handle the given MCP servers
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/agent_harness/providers/adapter.rb', line 148 def validate_mcp_servers!(mcp_servers) return if mcp_servers.nil? || mcp_servers.empty? unless supports_mcp? raise McpUnsupportedError.new( "Provider '#{self.class.provider_name}' does not support MCP servers", provider: self.class.provider_name ) end supported = supported_mcp_transports if supported.empty? raise McpUnsupportedError.new( "Provider '#{self.class.provider_name}' does not support request-time MCP servers", provider: self.class.provider_name ) end mcp_servers.each do |server| next if supported.include?(server.transport) raise McpTransportUnsupportedError.new( "Provider '#{self.class.provider_name}' does not support MCP transport " \ "'#{server.transport}' (server: '#{server.name}'). " \ "Supported transports: #{supported.join(", ")}", provider: self.class.provider_name ) end end |