Class: Kward::StandaloneAgent
- Inherits:
-
Object
- Object
- Kward::StandaloneAgent
- Defined in:
- lib/kward/shell/standalone_agent.rb
Overview
Lazy, in-memory shell conversation with no chat composer or tab startup.
Instance Method Summary collapse
- #ask(instruction, shell, cancellation:) ⇒ Object
-
#initialize(client: Client.new) ⇒ StandaloneAgent
constructor
A new instance of StandaloneAgent.
Constructor Details
#initialize(client: Client.new) ⇒ StandaloneAgent
Returns a new instance of StandaloneAgent.
7 8 9 |
# File 'lib/kward/shell/standalone_agent.rb', line 7 def initialize(client: Client.new) @client = client end |
Instance Method Details
#ask(instruction, shell, cancellation:) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/kward/shell/standalone_agent.rb', line 11 def ask(instruction, shell, cancellation:) @agent ||= build_agent(shell.cwd) session = ShellPromptSession.new(shell) registry = @agent.tool_registry.for_shell_prompt(session) answer = @agent.ask(ShellPrompt.input(instruction, session.context), display_input: "? #{instruction}", tool_registry: registry, cancellation: cancellation) [answer, session.prepared_command] end |