Class: PromptObjects::Context
- Inherits:
-
Object
- Object
- PromptObjects::Context
- Defined in:
- lib/prompt_objects/environment.rb
Overview
Context object passed to capabilities during execution. Provides access to environment, message bus, and tracks execution.
Instance Attribute Summary collapse
-
#bus ⇒ Object
readonly
Returns the value of attribute bus.
-
#calling_po ⇒ Object
Returns the value of attribute calling_po.
-
#current_capability ⇒ Object
Returns the value of attribute current_capability.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#human_queue ⇒ Object
readonly
Returns the value of attribute human_queue.
-
#tui_mode ⇒ Object
Returns the value of attribute tui_mode.
Instance Method Summary collapse
-
#env_data_scope ⇒ String?
Resolve the workspace scope for shared environment data.
-
#initialize(env:, bus:, human_queue: nil) ⇒ Context
constructor
A new instance of Context.
-
#log_message(to:, message:) ⇒ Object
Log a message to the bus.
-
#log_response(from:, message:) ⇒ Object
Log a response to the bus.
Constructor Details
#initialize(env:, bus:, human_queue: nil) ⇒ Context
Returns a new instance of Context.
10 11 12 13 14 15 16 17 |
# File 'lib/prompt_objects/environment.rb', line 10 def initialize(env:, bus:, human_queue: nil) @env = env @bus = bus @human_queue = human_queue @current_capability = nil @calling_po = nil # The PO that initiated the tool call (for resolving "self") @tui_mode = false end |
Instance Attribute Details
#bus ⇒ Object (readonly)
Returns the value of attribute bus.
7 8 9 |
# File 'lib/prompt_objects/environment.rb', line 7 def bus @bus end |
#calling_po ⇒ Object
Returns the value of attribute calling_po.
8 9 10 |
# File 'lib/prompt_objects/environment.rb', line 8 def calling_po @calling_po end |
#current_capability ⇒ Object
Returns the value of attribute current_capability.
8 9 10 |
# File 'lib/prompt_objects/environment.rb', line 8 def current_capability @current_capability end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
7 8 9 |
# File 'lib/prompt_objects/environment.rb', line 7 def env @env end |
#human_queue ⇒ Object (readonly)
Returns the value of attribute human_queue.
7 8 9 |
# File 'lib/prompt_objects/environment.rb', line 7 def human_queue @human_queue end |
#tui_mode ⇒ Object
Returns the value of attribute tui_mode.
8 9 10 |
# File 'lib/prompt_objects/environment.rb', line 8 def tui_mode @tui_mode end |
Instance Method Details
#env_data_scope ⇒ String?
Resolve the workspace scope for shared environment data.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/prompt_objects/environment.rb', line 21 def env_data_scope store = env.session_store return nil unless store if env.respond_to?(:env_data_scope) env.env_data_scope elsif env.respond_to?(:active_session_id) && env.active_session_id env.active_session_id end end |
#log_message(to:, message:) ⇒ Object
Log a message to the bus.
35 36 37 |
# File 'lib/prompt_objects/environment.rb', line 35 def (to:, message:) @bus.publish(from: @current_capability || "human", to: to, message: ) end |
#log_response(from:, message:) ⇒ Object
Log a response to the bus.
42 43 44 |
# File 'lib/prompt_objects/environment.rb', line 42 def log_response(from:, message:) @bus.publish(from: from, to: @current_capability || "human", message: ) end |