Class: RailsAiBridge::Config::ContextProviders

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/config/context_providers.rb

Overview

Holds outbound context-provider settings: enable switch, host allowlist, loopback ports, private-network override, timeouts, response limits, provider and tool count caps, aggregation budget, and downstream auth resolver.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContextProviders



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 43

def initialize
  @enabled = false
  @allowed_hosts = []
  @allowed_loopback_ports = [3000, 9292]
  @timeout_seconds = 10
  @aggregation_budget_seconds = 30
  @max_response_bytes = 1_048_576
  @max_providers = 8
  @max_tools_per_provider = 16
  @max_resolved_addresses = 8
  @allow_private_networks = false
  @auth_resolver = nil
end

Instance Attribute Details

#aggregation_budget_secondsNumeric

Returns total budget across all providers in one tool call, in seconds.

Returns:

  • (Numeric)

    total budget across all providers in one tool call, in seconds



28
29
30
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 28

def aggregation_budget_seconds
  @aggregation_budget_seconds
end

#allow_private_networksBoolean

Returns whether private/link-local network destinations are allowed.

Returns:

  • (Boolean)

    whether private/link-local network destinations are allowed



19
20
21
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 19

def allow_private_networks
  @allow_private_networks
end

#allowed_hostsArray<String>

Returns exact allowed hostnames; no wildcards or suffixes.

Returns:

  • (Array<String>)

    exact allowed hostnames; no wildcards or suffixes



13
14
15
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 13

def allowed_hosts
  @allowed_hosts
end

#allowed_loopback_portsArray<Integer>

Returns allowed loopback ports for HTTP development endpoints.

Returns:

  • (Array<Integer>)

    allowed loopback ports for HTTP development endpoints



16
17
18
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 16

def allowed_loopback_ports
  @allowed_loopback_ports
end

#auth_resolverProc?

Returns lambda returning auth headers for a configured provider identity.

Returns:

  • (Proc, nil)

    lambda returning auth headers for a configured provider identity



22
23
24
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 22

def auth_resolver
  @auth_resolver
end

#enabledBoolean

Returns whether outbound provider traffic is allowed.

Returns:

  • (Boolean)

    whether outbound provider traffic is allowed



10
11
12
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 10

def enabled
  @enabled
end

#max_providersInteger

Returns maximum providers to call in one tool invocation.

Returns:

  • (Integer)

    maximum providers to call in one tool invocation



34
35
36
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 34

def max_providers
  @max_providers
end

#max_resolved_addressesInteger

Returns maximum DNS addresses to resolve per endpoint.

Returns:

  • (Integer)

    maximum DNS addresses to resolve per endpoint



40
41
42
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 40

def max_resolved_addresses
  @max_resolved_addresses
end

#max_response_bytesInteger

Returns maximum provider response body size in bytes before normalization.

Returns:

  • (Integer)

    maximum provider response body size in bytes before normalization



31
32
33
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 31

def max_response_bytes
  @max_response_bytes
end

#max_tools_per_providerInteger

Returns maximum tools to call per provider.

Returns:

  • (Integer)

    maximum tools to call per provider



37
38
39
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 37

def max_tools_per_provider
  @max_tools_per_provider
end

#timeout_secondsNumeric

Returns per-tool connect/read timeout in seconds.

Returns:

  • (Numeric)

    per-tool connect/read timeout in seconds



25
26
27
# File 'lib/rails_ai_bridge/config/context_providers.rb', line 25

def timeout_seconds
  @timeout_seconds
end