Class: Kward::PluginRegistry::Context
- Inherits:
-
Object
- Object
- Kward::PluginRegistry::Context
- Defined in:
- lib/kward/plugin_registry.rb
Overview
Runtime context passed to plugin commands, footers, prompt context renderers, and transcript event handlers.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#workspace_root ⇒ Object
readonly
Returns the value of attribute workspace_root.
Instance Method Summary collapse
- #allow(message = nil, metadata: nil) ⇒ Object
- #ask(message = nil, metadata: nil) ⇒ Object
- #defer(message = nil, payload: nil, metadata: nil) ⇒ Object
- #deny(message = nil, metadata: nil) ⇒ Object
-
#initialize(conversation:, args: "", session: nil, workspace_root: Dir.pwd, say_callback: nil) ⇒ Context
constructor
Creates an object for trusted plugin loading and dispatch.
- #modify(payload, message: nil, metadata: nil) ⇒ Object
-
#refresh_system_message! ⇒ nil
Requests that the conversation rebuild its system message after plugin state changes that affect prompt context.
- #retry(message = nil, payload: nil, metadata: nil) ⇒ Object
-
#say(message) ⇒ nil
Emits command output to the active frontend when available.
- #session_id ⇒ Object
- #session_name ⇒ Object
- #session_path ⇒ Object
-
#transcript ⇒ Transcript
Read-only transcript wrapper.
- #warn(message = nil, metadata: nil) ⇒ Object
Constructor Details
#initialize(conversation:, args: "", session: nil, workspace_root: Dir.pwd, say_callback: nil) ⇒ Context
Creates an object for trusted plugin loading and dispatch.
68 69 70 71 72 73 74 |
# File 'lib/kward/plugin_registry.rb', line 68 def initialize(conversation:, args: "", session: nil, workspace_root: Dir.pwd, say_callback: nil) @conversation = conversation @args = args.to_s @session = session @workspace_root = workspace_root @say_callback = say_callback end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
65 66 67 |
# File 'lib/kward/plugin_registry.rb', line 65 def args @args end |
#workspace_root ⇒ Object (readonly)
Returns the value of attribute workspace_root.
65 66 67 |
# File 'lib/kward/plugin_registry.rb', line 65 def workspace_root @workspace_root end |
Instance Method Details
#allow(message = nil, metadata: nil) ⇒ Object
111 112 113 |
# File 'lib/kward/plugin_registry.rb', line 111 def allow( = nil, metadata: nil) Hooks::Decision.allow(, metadata: ) end |
#ask(message = nil, metadata: nil) ⇒ Object
119 120 121 |
# File 'lib/kward/plugin_registry.rb', line 119 def ask( = nil, metadata: nil) Hooks::Decision.ask(, metadata: ) end |
#defer(message = nil, payload: nil, metadata: nil) ⇒ Object
135 136 137 |
# File 'lib/kward/plugin_registry.rb', line 135 def defer( = nil, payload: nil, metadata: nil) Hooks::Decision.defer(, payload: payload, metadata: ) end |
#deny(message = nil, metadata: nil) ⇒ Object
115 116 117 |
# File 'lib/kward/plugin_registry.rb', line 115 def deny( = nil, metadata: nil) Hooks::Decision.deny(, metadata: ) end |
#modify(payload, message: nil, metadata: nil) ⇒ Object
123 124 125 |
# File 'lib/kward/plugin_registry.rb', line 123 def modify(payload, message: nil, metadata: nil) Hooks::Decision.modify(payload, message: , metadata: ) end |
#refresh_system_message! ⇒ nil
Requests that the conversation rebuild its system message after plugin state changes that affect prompt context.
106 107 108 109 |
# File 'lib/kward/plugin_registry.rb', line 106 def @conversation. if @conversation.respond_to?(:refresh_system_message!) nil end |
#retry(message = nil, payload: nil, metadata: nil) ⇒ Object
131 132 133 |
# File 'lib/kward/plugin_registry.rb', line 131 def retry( = nil, payload: nil, metadata: nil) Hooks::Decision.retry(, payload: payload, metadata: ) end |
#say(message) ⇒ nil
Emits command output to the active frontend when available.
85 86 87 88 |
# File 'lib/kward/plugin_registry.rb', line 85 def say() @say_callback&.call(.to_s) nil end |
#session_id ⇒ Object
90 91 92 |
# File 'lib/kward/plugin_registry.rb', line 90 def session_id @session&.id end |
#session_name ⇒ Object
94 95 96 |
# File 'lib/kward/plugin_registry.rb', line 94 def session_name @session&.name end |
#session_path ⇒ Object
98 99 100 |
# File 'lib/kward/plugin_registry.rb', line 98 def session_path @session&.path end |
#transcript ⇒ Transcript
Returns read-only transcript wrapper.
77 78 79 |
# File 'lib/kward/plugin_registry.rb', line 77 def transcript Transcript.new(@conversation) end |