Class: Kward::PluginRegistry::DSL
- Inherits:
-
Object
- Object
- Kward::PluginRegistry::DSL
- Defined in:
- lib/kward/plugin_registry.rb
Overview
Public DSL object yielded by Kward.plugin blocks.
Plugin files normally interact with this object only through a block:
Instance Method Summary collapse
-
#command(name, description: "", argument_hint: "") {|args, ctx| ... } ⇒ void
Registers a slash command.
-
#footer {|ctx| ... } ⇒ void
Registers or replaces the custom footer renderer.
-
#hook(event, id: nil, description: "", order: 100, match: nil, failure_policy: nil) {|event, ctx| ... } ⇒ void
Registers a lifecycle hook handler.
-
#initialize(registry, path) ⇒ DSL
constructor
Creates an object for trusted plugin loading and dispatch.
-
#interactive_command(name, rows:, fps: 30, description: "", argument_hint: "") {|ui, ctx| ... } ⇒ void
Registers an interactive command that takes over the composer region with a Kward-driven render and input loop.
-
#on_transcript_event {|event, ctx| ... } ⇒ void
Registers a live transcript event observer.
-
#prompt_context {|ctx| ... } ⇒ void
Registers prompt context text injected into future system prompts.
-
#tab_type(name, id:, title: nil, singleton: nil, rpc: false, transport: false, local: true, transcript_events: false) {|host, descriptor| ... } ⇒ void
Registers a plugin-owned chat type.
-
#transport(name, id:, capabilities: nil, execution_profile: nil) {|host, config| ... } ⇒ void
Registers an external messaging or event transport.
Constructor Details
#initialize(registry, path) ⇒ DSL
Creates an object for trusted plugin loading and dispatch.
182 183 184 185 |
# File 'lib/kward/plugin_registry.rb', line 182 def initialize(registry, path) @registry = registry @path = path end |
Instance Method Details
#command(name, description: "", argument_hint: "") {|args, ctx| ... } ⇒ void
This method returns an undefined value.
Registers a slash command.
The command is available in the interactive CLI and through the RPC
command bridge. Command names do not include the leading /.
199 200 201 |
# File 'lib/kward/plugin_registry.rb', line 199 def command(name, description: "", argument_hint: "", &block) @registry.register_command(name, description: description, argument_hint: argument_hint, path: @path, &block) end |
#footer {|ctx| ... } ⇒ void
This method returns an undefined value.
Registers or replaces the custom footer renderer.
Only one footer renderer is active. If multiple plugins register one, the later renderer replaces the earlier renderer.
211 212 213 |
# File 'lib/kward/plugin_registry.rb', line 211 def (&block) @registry.(path: @path, &block) end |
#hook(event, id: nil, description: "", order: 100, match: nil, failure_policy: nil) {|event, ctx| ... } ⇒ void
This method returns an undefined value.
Registers a lifecycle hook handler.
Hooks are deterministic runtime callbacks around Kward lifecycle events. They can return a Hooks::Decision, a decision hash, a decision string, or nil to allow the operation.
243 244 245 |
# File 'lib/kward/plugin_registry.rb', line 243 def hook(event, id: nil, description: "", order: 100, match: nil, failure_policy: nil, &block) @registry.register_hook(event, id: id, description: description, order: order, match: match, failure_policy: failure_policy, path: @path, &block) end |
#interactive_command(name, rows:, fps: 30, description: "", argument_hint: "") {|ui, ctx| ... } ⇒ void
This method returns an undefined value.
Registers an interactive command that takes over the composer region with a Kward-driven render and input loop. The handler receives an interactive controller object with a canvas API for drawing colored cells and reading keys. Useful for games, dashboards, and viewers.
273 274 275 |
# File 'lib/kward/plugin_registry.rb', line 273 def interactive_command(name, rows:, fps: 30, description: "", argument_hint: "", &block) @registry.register_interactive_command(name, rows: rows, fps: fps, description: description, argument_hint: argument_hint, path: @path, &block) end |
#on_transcript_event {|event, ctx| ... } ⇒ void
This method returns an undefined value.
Registers a live transcript event observer.
Observer errors are caught and reported as warnings so a plugin cannot crash the active turn by raising from an event handler.
224 225 226 |
# File 'lib/kward/plugin_registry.rb', line 224 def on_transcript_event(&block) @registry.register_transcript_event(path: @path, &block) end |
#prompt_context {|ctx| ... } ⇒ void
This method returns an undefined value.
Registers prompt context text injected into future system prompts.
Keep this text short and never include secrets. The returned string can be sent to the active model as part of Kward's system instructions.
255 256 257 |
# File 'lib/kward/plugin_registry.rb', line 255 def prompt_context(&block) @registry.register_prompt_context(path: @path, &block) end |
#tab_type(name, id:, title: nil, singleton: nil, rpc: false, transport: false, local: true, transcript_events: false) {|host, descriptor| ... } ⇒ void
This method returns an undefined value.
Registers a plugin-owned chat type. id is a durable identifier used
in persisted tab layouts and transport chat handles and must not change.
The factory receives a PluginTabHost and a descriptor hash.
293 294 295 |
# File 'lib/kward/plugin_registry.rb', line 293 def tab_type(name, id:, title: nil, singleton: nil, rpc: false, transport: false, local: true, transcript_events: false, &block) @registry.register_tab_type(name, id: id, title: title, singleton: singleton, rpc: rpc, transport: transport, local: local, transcript_events: transcript_events, path: @path, &block) end |
#transport(name, id:, capabilities: nil, execution_profile: nil) {|host, config| ... } ⇒ void
This method returns an undefined value.
Registers an external messaging or event transport. The factory is called when the transport runtime starts.
307 308 309 |
# File 'lib/kward/plugin_registry.rb', line 307 def transport(name, id:, capabilities: nil, execution_profile: nil, &block) @registry.register_transport(name, id: id, capabilities: capabilities, execution_profile: execution_profile, path: @path, &block) end |