Module: Aidp::Harness::ProviderTypeChecker
- Included in:
- ConfigManager, ProviderConfig
- Defined in:
- lib/aidp/harness/provider_type_checker.rb
Overview
Shared module for provider type checking functionality This eliminates duplication across ProviderConfig and ConfigManager
Instance Method Summary collapse
-
#get_provider_type(provider_name, options = {}) ⇒ Object
Get provider type with fallback to subscription (ConfigManager signature).
-
#get_underlying_service(provider_name_or_options = {}, options = {}) ⇒ Object
Get underlying service name for passthrough providers.
-
#has_underlying_service?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider has underlying service (passthrough).
-
#passthrough_provider?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider is passthrough (inherits billing from underlying service).
-
#requires_api_key?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider requires API key.
-
#subscription_provider?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider is subscription-based (unlimited within limits).
-
#usage_based_provider?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider is usage-based (pay per token).
Instance Method Details
#get_provider_type(provider_name, options = {}) ⇒ Object
Get provider type with fallback to subscription (ConfigManager signature)
44 45 46 47 48 49 |
# File 'lib/aidp/harness/provider_type_checker.rb', line 44 def get_provider_type(provider_name, = {}) provider_config = provider_config(provider_name, ) return "subscription" unless provider_config provider_config[:type] || provider_config["type"] || "subscription" end |
#get_underlying_service(provider_name_or_options = {}, options = {}) ⇒ Object
Get underlying service name for passthrough providers
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/aidp/harness/provider_type_checker.rb', line 73 def ( = {}, = {}) return nil unless passthrough_provider?(, ) if .is_a?(String) || .is_a?(Symbol) provider_name = provider_config = provider_config(provider_name, ) else = provider_config = get_config() end provider_config[:underlying_service] || provider_config["underlying_service"] end |
#has_underlying_service?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider has underlying service (passthrough)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/aidp/harness/provider_type_checker.rb', line 57 def ( = {}, = {}) return false unless passthrough_provider?(, ) if .is_a?(String) || .is_a?(Symbol) provider_name = provider_config = provider_config(provider_name, ) else = provider_config = get_config() end = provider_config[:underlying_service] || provider_config["underlying_service"] !.nil? && !.empty? end |
#passthrough_provider?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider is passthrough (inherits billing from underlying service)
33 34 35 36 37 38 39 40 41 |
# File 'lib/aidp/harness/provider_type_checker.rb', line 33 def passthrough_provider?( = {}, = {}) if .is_a?(String) || .is_a?(Symbol) provider_name = get_provider_type(provider_name, ) == "passthrough" else = type() == "passthrough" end end |
#requires_api_key?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider requires API key
52 53 54 |
# File 'lib/aidp/harness/provider_type_checker.rb', line 52 def requires_api_key?( = {}, = {}) usage_based_provider?(, ) end |
#subscription_provider?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider is subscription-based (unlimited within limits)
22 23 24 25 26 27 28 29 30 |
# File 'lib/aidp/harness/provider_type_checker.rb', line 22 def subscription_provider?( = {}, = {}) if .is_a?(String) || .is_a?(Symbol) provider_name = get_provider_type(provider_name, ) == "subscription" else = type() == "subscription" end end |
#usage_based_provider?(provider_name_or_options = {}, options = {}) ⇒ Boolean
Check if provider is usage-based (pay per token)
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/aidp/harness/provider_type_checker.rb', line 9 def usage_based_provider?( = {}, = {}) # Handle both ConfigManager (provider_name, options) and ProviderConfig (options) signatures if .is_a?(String) || .is_a?(Symbol) provider_name = get_provider_type(provider_name, ) == "usage_based" else # ProviderConfig signature: usage_based_provider?(options) = type() == "usage_based" end end |