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.

Examples:

Implementing a provider

class MyProvider < AgentHarness::Providers::Base
  include AgentHarness::Providers::Adapter

  def self.provider_name
    :my_provider
  end
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

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

#capabilitiesHash

Provider capabilities

Returns:

  • (Hash)

    capability flags



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_flagsArray<String>

Get dangerous mode flags

Returns:

  • (Array<String>)

    CLI flags for dangerous mode



129
130
131
# File 'lib/agent_harness/providers/adapter.rb', line 129

def dangerous_mode_flags
  []
end

#error_patternsHash<Symbol, Array<Regexp>>

Error patterns for classification

Returns:

  • (Hash<Symbol, Array<Regexp>>)

    error patterns by category



101
102
103
# File 'lib/agent_harness/providers/adapter.rb', line 101

def error_patterns
  {}
end

#fetch_mcp_serversArray<Hash>

Fetch configured MCP servers

Returns:

  • (Array<Hash>)

    MCP server configurations



115
116
117
# File 'lib/agent_harness/providers/adapter.rb', line 115

def fetch_mcp_servers
  []
end

#health_statusHash

Health check

Returns:

  • (Hash)

    with :healthy, :message keys



158
159
160
# File 'lib/agent_harness/providers/adapter.rb', line 158

def health_status
  {healthy: true, message: "OK"}
end

#send_message(prompt:, **options) ⇒ Response

Send a message/prompt to the provider

Parameters:

  • prompt (String)

    the prompt to send

  • options (Hash)

    provider-specific options

Options Hash (**options):

  • :model (String)

    model to use

  • :timeout (Integer)

    timeout in seconds

  • :session (String)

    session identifier

  • :dangerous_mode (Boolean)

    skip permission checks

Returns:

  • (Response)

    response object with output and metadata

Raises:

  • (NotImplementedError)


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

def send_message(prompt:, **options)
  raise NotImplementedError, "#{self.class} must implement #send_message"
end

#session_flags(session_id) ⇒ Array<String>

Get session flags for continuation

Parameters:

  • session_id (String)

    the session ID

Returns:

  • (Array<String>)

    CLI flags for session continuation



144
145
146
# File 'lib/agent_harness/providers/adapter.rb', line 144

def session_flags(session_id)
  []
end

#supports_dangerous_mode?Boolean

Check if provider supports dangerous mode

Returns:

  • (Boolean)

    true if dangerous mode is supported



122
123
124
# File 'lib/agent_harness/providers/adapter.rb', line 122

def supports_dangerous_mode?
  capabilities[:dangerous_mode]
end

#supports_mcp?Boolean

Check if provider supports MCP

Returns:

  • (Boolean)

    true if MCP is supported



108
109
110
# File 'lib/agent_harness/providers/adapter.rb', line 108

def supports_mcp?
  capabilities[:mcp]
end

#supports_sessions?Boolean

Check if provider supports session continuation

Returns:

  • (Boolean)

    true if sessions are supported



136
137
138
# File 'lib/agent_harness/providers/adapter.rb', line 136

def supports_sessions?
  false
end

#validate_configHash

Validate provider configuration

Returns:

  • (Hash)

    with :valid, :errors keys



151
152
153
# File 'lib/agent_harness/providers/adapter.rb', line 151

def validate_config
  {valid: true, errors: []}
end