Class: AgentCliRuntime::Route
- Inherits:
-
Data
- Object
- Data
- AgentCliRuntime::Route
- Defined in:
- lib/agent_cli_runtime/values.rb
Constant Summary collapse
- ROUTE_PATTERN =
/\A(?<provider>[a-zA-Z0-9][a-zA-Z0-9._-]*)\/(?<model>[^\s\/][^\s]*)\z/
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(provider:, model:) ⇒ Route
constructor
A new instance of Route.
- #to_s ⇒ Object
Constructor Details
#initialize(provider:, model:) ⇒ Route
Returns a new instance of Route.
210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/agent_cli_runtime/values.rb', line 210 def initialize(provider:, model:) normalized_provider = Immutable.string(provider) normalized_model = Immutable.string(model) route = "#{normalized_provider}/#{normalized_model}" unless ROUTE_PATTERN.match?(route) && !normalized_model.include?("\0") raise ArgumentError, "OpenCode route must be a full provider/model value" end super(provider: normalized_provider, model: normalized_model) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model
207 208 209 |
# File 'lib/agent_cli_runtime/values.rb', line 207 def model @model end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider
207 208 209 |
# File 'lib/agent_cli_runtime/values.rb', line 207 def provider @provider end |
Class Method Details
.parse(value) ⇒ Object
222 223 224 225 226 227 228 229 230 |
# File 'lib/agent_cli_runtime/values.rb', line 222 def self.parse(value) match = ROUTE_PATTERN.match(value.to_s) unless match raise ArgumentError, "OpenCode route must be a full provider/model value" end new(provider: match[:provider], model: match[:model]) end |
Instance Method Details
#to_s ⇒ Object
232 233 234 |
# File 'lib/agent_cli_runtime/values.rb', line 232 def to_s "#{provider}/#{model}" end |