Class: Aidp::AgentHarnessAdapter
- Inherits:
-
Object
- Object
- Aidp::AgentHarnessAdapter
- Defined in:
- lib/aidp/agent_harness_adapter.rb
Overview
Instance Attribute Summary collapse
-
#conductor ⇒ Object
readonly
Returns the value of attribute conductor.
Instance Method Summary collapse
-
#initialize(aidp_config, logger: nil) ⇒ AgentHarnessAdapter
constructor
Create a new adapter.
-
#on_tokens_used {|TokenEvent| ... } ⇒ Object
Register callback for token events.
-
#provider(name) ⇒ AgentHarness::Providers::Base
Get a specific provider instance.
-
#provider_available?(name) ⇒ Boolean
Check if a provider is available.
-
#reset! ⇒ Object
Reset the adapter (useful for testing).
-
#send_message(prompt:, provider: nil, **options) ⇒ Hash
Send a message through AgentHarness.
-
#status ⇒ Hash
Get orchestration status.
-
#token_summary ⇒ Hash
Get token usage summary.
Constructor Details
#initialize(aidp_config, logger: nil) ⇒ AgentHarnessAdapter
Create a new adapter
64 65 66 67 68 69 |
# File 'lib/aidp/agent_harness_adapter.rb', line 64 def initialize(aidp_config, logger: nil) @aidp_config = aidp_config @logger = logger || Aidp.logger configure_agent_harness end |
Instance Attribute Details
#conductor ⇒ Object (readonly)
Returns the value of attribute conductor.
58 59 60 |
# File 'lib/aidp/agent_harness_adapter.rb', line 58 def conductor @conductor end |
Instance Method Details
#on_tokens_used {|TokenEvent| ... } ⇒ Object
Register callback for token events
132 133 134 |
# File 'lib/aidp/agent_harness_adapter.rb', line 132 def on_tokens_used(&block) AgentHarness.token_tracker.on_tokens_used(&block) end |
#provider(name) ⇒ AgentHarness::Providers::Base
Get a specific provider instance
100 101 102 |
# File 'lib/aidp/agent_harness_adapter.rb', line 100 def provider(name) @conductor.provider_manager.get_provider(name) end |
#provider_available?(name) ⇒ Boolean
Check if a provider is available
108 109 110 111 112 113 |
# File 'lib/aidp/agent_harness_adapter.rb', line 108 def provider_available?(name) provider_class = AgentHarness::Providers::Registry.instance.get(name) provider_class.available? rescue AgentHarness::ConfigurationError false end |
#reset! ⇒ Object
Reset the adapter (useful for testing)
137 138 139 140 |
# File 'lib/aidp/agent_harness_adapter.rb', line 137 def reset! @conductor.reset! AgentHarness.token_tracker.clear! end |
#send_message(prompt:, provider: nil, **options) ⇒ Hash
Send a message through AgentHarness
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/aidp/agent_harness_adapter.rb', line 77 def (prompt:, provider: nil, **) start_time = Time.now # Map AIDP options to AgentHarness options = () # Use the conductor for orchestrated requests response = @conductor.(prompt, provider: provider, **) # Convert Response to AIDP-compatible hash convert_response(response, Time.now - start_time) rescue AgentHarness::RateLimitError => e handle_rate_limit(e, provider) rescue AgentHarness::NoProvidersAvailableError => e handle_no_providers(e) rescue AgentHarness::Error => e handle_error(e, provider) end |
#status ⇒ Hash
Get orchestration status
118 119 120 |
# File 'lib/aidp/agent_harness_adapter.rb', line 118 def status @conductor.status end |
#token_summary ⇒ Hash
Get token usage summary
125 126 127 |
# File 'lib/aidp/agent_harness_adapter.rb', line 125 def token_summary AgentHarness.token_tracker.summary end |