Module: AgentHarness
- Defined in:
- lib/agent_harness.rb,
lib/agent_harness/errors.rb,
lib/agent_harness/version.rb,
lib/agent_harness/response.rb,
lib/agent_harness/mcp_server.rb,
lib/agent_harness/configuration.rb,
lib/agent_harness/token_tracker.rb,
lib/agent_harness/authentication.rb,
lib/agent_harness/error_taxonomy.rb,
lib/agent_harness/providers/base.rb,
lib/agent_harness/text_transport.rb,
lib/agent_harness/providers/aider.rb,
lib/agent_harness/providers/codex.rb,
lib/agent_harness/command_executor.rb,
lib/agent_harness/provider_runtime.rb,
lib/agent_harness/providers/cursor.rb,
lib/agent_harness/providers/gemini.rb,
lib/agent_harness/providers/adapter.rb,
lib/agent_harness/providers/kilocode.rb,
lib/agent_harness/providers/opencode.rb,
lib/agent_harness/providers/registry.rb,
lib/agent_harness/providers/anthropic.rb,
lib/agent_harness/execution_preparation.rb,
lib/agent_harness/orchestration/metrics.rb,
lib/agent_harness/provider_health_check.rb,
lib/agent_harness/providers/mistral_vibe.rb,
lib/agent_harness/docker_command_executor.rb,
lib/agent_harness/orchestration/conductor.rb,
lib/agent_harness/providers/github_copilot.rb,
lib/agent_harness/orchestration/rate_limiter.rb,
lib/agent_harness/orchestration/health_monitor.rb,
lib/agent_harness/orchestration/circuit_breaker.rb,
lib/agent_harness/providers/token_usage_parsing.rb,
lib/agent_harness/orchestration/provider_manager.rb
Overview
AgentHarness provides a unified interface for CLI-based AI coding agents.
It offers:
-
Unified interface for multiple AI coding agents (Claude Code, Cursor, Gemini CLI, etc.)
-
Full orchestration layer with provider switching, circuit breakers, and health monitoring
-
Flexible configuration via YAML, Ruby DSL, or environment variables
-
Dynamic provider registration for custom provider support
-
Token usage tracking for cost and limit calculations
Defined Under Namespace
Modules: Authentication, ErrorTaxonomy, Orchestration, Providers Classes: AuthMismatchError, AuthenticationError, CallbackRegistry, CircuitBreakerConfig, CircuitOpenError, CommandExecutionError, CommandExecutor, Configuration, ConfigurationError, DockerCommandExecutor, Error, ExecutionPreparation, HealthCheckConfig, IdleTimeoutError, InvalidDurationError, McpConfigurationError, McpServer, McpTransportUnsupportedError, McpUnsupportedError, NoProvidersAvailableError, OrchestrationConfig, ProviderConfig, ProviderError, ProviderHealthCheck, ProviderNotFoundError, ProviderRuntime, ProviderUnavailableError, RateLimitConfig, RateLimitError, Response, RetryConfig, TextTransport, TimeoutError, TokenTracker
Constant Summary collapse
- VERSION =
"0.7.3"
Class Method Summary collapse
-
.auth_status(provider_name) ⇒ Hash
Get detailed authentication status for a provider.
-
.auth_url(provider_name) ⇒ String
Generate an OAuth URL for a provider.
-
.auth_valid?(provider_name) ⇒ Boolean
Check if authentication is valid for a provider.
-
.check_provider(provider_name, timeout: nil, executor: nil, provider_runtime: nil) ⇒ Hash
Check health of a single provider.
-
.check_providers(timeout: nil, executor: nil, provider_runtime: nil) ⇒ Array<Hash>
Check health of all configured providers.
-
.conductor ⇒ Orchestration::Conductor
Returns the global conductor for orchestrated requests.
-
.configuration ⇒ Configuration
Returns the global configuration instance.
-
.configure {|Configuration| ... } ⇒ void
Configure AgentHarness with a block.
-
.install_contract(name) ⇒ Hash
Get install contract metadata for a provider.
-
.installation_contract(provider_name, **options) ⇒ Hash?
Get installation metadata for a provider CLI.
-
.installation_contracts ⇒ Hash<Symbol, Hash>
Get all provider installation contracts exposed by agent-harness.
-
.logger ⇒ Logger?
Returns the global logger.
-
.provider(name) ⇒ Providers::Base
Get a provider instance.
-
.provider_install_contract(provider_name, version: nil) ⇒ Hash?
Returns install metadata for a provider CLI when the provider exposes it.
-
.provider_installation_contract(name, **options) ⇒ Hash?
Get the installation contract for a provider CLI.
-
.provider_metadata(provider_name, refresh: false) ⇒ Hash
Get consolidated metadata for a provider.
-
.provider_metadata_catalog(refresh: false) ⇒ Hash<Symbol, Hash>
Get consolidated metadata for all registered providers.
-
.provider_smoke_test_contract(provider_name) ⇒ Hash?
Get smoke-test metadata for a provider CLI when the provider exposes it.
-
.refresh_auth(provider_name, token: nil) ⇒ Hash
Refresh authentication credentials for a provider.
-
.reset! ⇒ void
Reset configuration to defaults (useful for testing).
-
.send_message(prompt, provider: nil, executor: nil, **options) ⇒ Response
Send a message using the orchestration layer.
-
.smoke_test_contract(provider_name) ⇒ Hash?
Get smoke-test metadata for a provider CLI.
-
.smoke_test_contracts ⇒ Hash<Symbol, Hash>
Get all provider smoke-test contracts exposed by agent-harness.
-
.token_tracker ⇒ TokenTracker
Returns the global token tracker.
Class Method Details
.auth_status(provider_name) ⇒ Hash
Get detailed authentication status for a provider
183 184 185 |
# File 'lib/agent_harness.rb', line 183 def auth_status(provider_name) Authentication.auth_status(provider_name) end |
.auth_url(provider_name) ⇒ String
Generate an OAuth URL for a provider
191 192 193 |
# File 'lib/agent_harness.rb', line 191 def auth_url(provider_name) Authentication.auth_url(provider_name) end |
.auth_valid?(provider_name) ⇒ Boolean
Check if authentication is valid for a provider
176 177 178 |
# File 'lib/agent_harness.rb', line 176 def auth_valid?(provider_name) Authentication.auth_valid?(provider_name) end |
.check_provider(provider_name, timeout: nil, executor: nil, provider_runtime: nil) ⇒ Hash
Check health of a single provider
227 228 229 230 231 232 233 |
# File 'lib/agent_harness.rb', line 227 def check_provider(provider_name, timeout: nil, executor: nil, provider_runtime: nil) = {} [:timeout] = timeout unless timeout.nil? [:executor] = executor unless executor.nil? [:provider_runtime] = provider_runtime unless provider_runtime.nil? ProviderHealthCheck.check(provider_name, **) end |
.check_providers(timeout: nil, executor: nil, provider_runtime: nil) ⇒ Array<Hash>
Check health of all configured providers.
Validates each enabled provider through registration, CLI availability, authentication, provider health status, and config validation checks.
214 215 216 217 218 219 220 221 |
# File 'lib/agent_harness.rb', line 214 def check_providers(timeout: nil, executor: nil, provider_runtime: nil) raise ArgumentError, "provider_runtime is only supported for single-provider health checks" unless provider_runtime.nil? = {} [:timeout] = timeout unless timeout.nil? [:executor] = executor unless executor.nil? ProviderHealthCheck.check_all(**) end |
.conductor ⇒ Orchestration::Conductor
Returns the global conductor for orchestrated requests
66 67 68 |
# File 'lib/agent_harness.rb', line 66 def conductor @conductor ||= Orchestration::Conductor.new(config: configuration) end |
.configuration ⇒ Configuration
Returns the global configuration instance
33 34 35 |
# File 'lib/agent_harness.rb', line 33 def configuration @configuration ||= Configuration.new end |
.configure {|Configuration| ... } ⇒ void
This method returns an undefined value.
Configure AgentHarness with a block
40 41 42 |
# File 'lib/agent_harness.rb', line 40 def configure yield(configuration) if block_given? end |
.install_contract(name) ⇒ Hash
Get install contract metadata for a provider
91 92 93 |
# File 'lib/agent_harness.rb', line 91 def install_contract(name) Providers::Registry.instance.install_contract(name) end |
.installation_contract(provider_name, **options) ⇒ Hash?
Get installation metadata for a provider CLI.
119 120 121 |
# File 'lib/agent_harness.rb', line 119 def installation_contract(provider_name, **) Providers::Registry.instance.installation_contract(provider_name, **) end |
.installation_contracts ⇒ Hash<Symbol, Hash>
Get all provider installation contracts exposed by agent-harness.
125 126 127 |
# File 'lib/agent_harness.rb', line 125 def installation_contracts Providers::Registry.instance.installation_contracts end |
.logger ⇒ Logger?
Returns the global logger
54 55 56 |
# File 'lib/agent_harness.rb', line 54 def logger configuration.logger end |
.provider(name) ⇒ Providers::Base
Get a provider instance
83 84 85 |
# File 'lib/agent_harness.rb', line 83 def provider(name) conductor.provider_manager.get_provider(name) end |
.provider_install_contract(provider_name, version: nil) ⇒ Hash?
Returns install metadata for a provider CLI when the provider exposes it.
100 101 102 |
# File 'lib/agent_harness.rb', line 100 def provider_install_contract(provider_name, version: nil) provider_installation_contract(provider_name, **(version ? {version: version} : {})) end |
.provider_installation_contract(name, **options) ⇒ Hash?
Get the installation contract for a provider CLI.
110 111 112 |
# File 'lib/agent_harness.rb', line 110 def provider_installation_contract(name, **) Providers::Registry.instance.installation_contract(name, **) end |
.provider_metadata(provider_name, refresh: false) ⇒ Hash
Get consolidated metadata for a provider.
136 137 138 |
# File 'lib/agent_harness.rb', line 136 def (provider_name, refresh: false) Providers::Registry.instance.(provider_name, refresh: refresh) end |
.provider_metadata_catalog(refresh: false) ⇒ Hash<Symbol, Hash>
Get consolidated metadata for all registered providers.
145 146 147 |
# File 'lib/agent_harness.rb', line 145 def (refresh: false) Providers::Registry.instance.(refresh: refresh) end |
.provider_smoke_test_contract(provider_name) ⇒ Hash?
Get smoke-test metadata for a provider CLI when the provider exposes it.
153 154 155 |
# File 'lib/agent_harness.rb', line 153 def provider_smoke_test_contract(provider_name) smoke_test_contract(provider_name) end |
.refresh_auth(provider_name, token: nil) ⇒ Hash
Refresh authentication credentials for a provider
200 201 202 |
# File 'lib/agent_harness.rb', line 200 def refresh_auth(provider_name, token: nil) Authentication.refresh_auth(provider_name, token: token) end |
.reset! ⇒ void
This method returns an undefined value.
Reset configuration to defaults (useful for testing)
46 47 48 49 50 |
# File 'lib/agent_harness.rb', line 46 def reset! @configuration = nil @conductor = nil @token_tracker = nil end |
.send_message(prompt, provider: nil, executor: nil, **options) ⇒ Response
Send a message using the orchestration layer
76 77 78 |
# File 'lib/agent_harness.rb', line 76 def (prompt, provider: nil, executor: nil, **) conductor.(prompt, provider: provider, executor: executor, **) end |
.smoke_test_contract(provider_name) ⇒ Hash?
Get smoke-test metadata for a provider CLI.
161 162 163 164 165 |
# File 'lib/agent_harness.rb', line 161 def smoke_test_contract(provider_name) # Explicitly raise if provider is not registered to match documentation raise ConfigurationError, "Unknown provider: #{provider_name}" unless Providers::Registry.instance.registered?(provider_name) Providers::Registry.instance.smoke_test_contract(provider_name) end |
.smoke_test_contracts ⇒ Hash<Symbol, Hash>
Get all provider smoke-test contracts exposed by agent-harness.
169 170 171 |
# File 'lib/agent_harness.rb', line 169 def smoke_test_contracts Providers::Registry.instance.smoke_test_contracts end |
.token_tracker ⇒ TokenTracker
Returns the global token tracker
60 61 62 |
# File 'lib/agent_harness.rb', line 60 def token_tracker @token_tracker ||= TokenTracker.new end |