Class: RubyCoded::Chat::RuntimeMode
- Inherits:
-
Object
- Object
- RubyCoded::Chat::RuntimeMode
- Defined in:
- lib/ruby_coded/chat/runtime_mode.rb
Overview
Value object representing the runtime mode of the assistant.
Modes are the single source of truth for tool availability, prompt selection, mutation permission, and confirmation policy. Bridges hold a RuntimeMode instance instead of independent boolean flags to avoid inconsistent combinations.
Constant Summary collapse
- NAMES =
%i[chat agent plan].freeze
- CHAT =
new(:chat)
- AGENT =
new(:agent)
- PLAN =
new(:plan)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #agent? ⇒ Boolean
-
#allows_mutation? ⇒ Boolean
Destructive/write tools are permitted only in agent mode.
-
#allows_tools? ⇒ Boolean
Tools may be invoked in this mode (readonly for plan, full for agent).
- #chat? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name) ⇒ RuntimeMode
constructor
A new instance of RuntimeMode.
- #plan? ⇒ Boolean
-
#requires_confirmation? ⇒ Boolean
User confirmation is required for non-safe tools outside chat mode.
-
#skill_mode ⇒ Object
Symbol used when querying skills for this mode.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ RuntimeMode
Returns a new instance of RuntimeMode.
16 17 18 19 20 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 16 def initialize(name) raise ArgumentError, "unknown mode: #{name.inspect}" unless NAMES.include?(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 14 def name @name end |
Class Method Details
.agent ⇒ Object
76 77 78 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 76 def agent AGENT end |
.chat ⇒ Object
72 73 74 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 72 def chat CHAT end |
.for(value) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 84 def for(value) return value if value.is_a?(RuntimeMode) case value.to_sym when :chat then CHAT when :agent then AGENT when :plan then PLAN else raise ArgumentError, "unknown mode: #{value.inspect}" end end |
.plan ⇒ Object
80 81 82 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 80 def plan PLAN end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
58 59 60 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 58 def ==(other) other.is_a?(RuntimeMode) && other.name == @name end |
#agent? ⇒ Boolean
26 27 28 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 26 def agent? @name == :agent end |
#allows_mutation? ⇒ Boolean
Destructive/write tools are permitted only in agent mode.
40 41 42 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 40 def allows_mutation? agent? end |
#allows_tools? ⇒ Boolean
Tools may be invoked in this mode (readonly for plan, full for agent).
35 36 37 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 35 def allows_tools? agent? || plan? end |
#chat? ⇒ Boolean
22 23 24 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 22 def chat? @name == :chat end |
#hash ⇒ Object
63 64 65 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 63 def hash [self.class, @name].hash end |
#plan? ⇒ Boolean
30 31 32 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 30 def plan? @name == :plan end |
#requires_confirmation? ⇒ Boolean
User confirmation is required for non-safe tools outside chat mode.
45 46 47 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 45 def requires_confirmation? agent? || plan? end |
#skill_mode ⇒ Object
Symbol used when querying skills for this mode.
50 51 52 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 50 def skill_mode @name end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/ruby_coded/chat/runtime_mode.rb', line 54 def to_s @name.to_s end |